From 93a8fc4e0ce13937306b4f26a87f513794b53638 Mon Sep 17 00:00:00 2001 From: Anuragkillswitch <70265851+Anuragkillswitch@users.noreply.github.com> Date: Tue, 31 Jan 2023 09:24:11 +0530 Subject: [PATCH] Fix issue 2567: NoneType check before raising exception --- redis/connection.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/redis/connection.py b/redis/connection.py index 57f0a3a81e..dc25742dff 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -334,11 +334,12 @@ def can_read(self, timeout): return self._buffer and self._buffer.can_read(timeout) def read_response(self, disable_decoding=False): - pos = self._buffer.get_pos() + pos = self._buffer.get_pos() if self._buffer else None try: result = self._read_response(disable_decoding=disable_decoding) except BaseException: - self._buffer.rewind(pos) + if self._buffer: + self._buffer.rewind(pos) raise else: self._buffer.purge()