Skip to content

Commit

Permalink
Fix issue 2567: NoneType check before raising exception (#2569)
Browse files Browse the repository at this point in the history
Co-authored-by: Anuragkillswitch <70265851+Anuragkillswitch@users.noreply.github.com>
  • Loading branch information
SoulPancake and SoulPancake committed Feb 6, 2023
1 parent ffbe879 commit 9e00b91
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions redis/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,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()
Expand Down

0 comments on commit 9e00b91

Please sign in to comment.