Fix issue 2567: NoneType check before raising exception
@@ -340,10 +340,11 @@ class PythonParser(BaseParser):
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:
+ if self._buffer:
self._buffer.rewind(pos)
raise
else:
