diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2019-08-02 15:13:04 -0700 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2019-08-02 15:13:04 -0700 |
commit | a5ba696ed8aa3efbc709de4046a121a82a31392f (patch) | |
tree | db14534b0594c80372c5817018b17e59e78fc7e4 | |
parent | 3afa016029d7e0a46fa1d76ac9c7463a02495e05 (diff) | |
download | redis-py-a5ba696ed8aa3efbc709de4046a121a82a31392f.tar.gz |
version 3.3.5, handle socket.timeout errors correctly in Python 2.73.3.5
Fix an issue where socket.timeout errors could be handled by the wrong
exception handler in Python 2.7.
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | redis/__init__.py | 2 | ||||
-rwxr-xr-x | redis/connection.py | 24 |
3 files changed, 12 insertions, 17 deletions
@@ -1,3 +1,6 @@ +* 3.3.5 + * Fix an issue where socket.timeout errors could be handled by the wrong + exception handler in Python 2.7. * 3.3.4 * More specifically identify nonblocking read errors for both SSL and non-SSL connections. 3.3.1, 3.3.2 and 3.3.3 on Python 2.7 could diff --git a/redis/__init__.py b/redis/__init__.py index 71bc217..66ef979 100644 --- a/redis/__init__.py +++ b/redis/__init__.py @@ -29,7 +29,7 @@ def int_or_str(value): return value -__version__ = '3.3.4' +__version__ = '3.3.5' VERSION = tuple(map(int_or_str, __version__.split('.'))) __all__ = [ diff --git a/redis/connection.py b/redis/connection.py index 28b579e..151d4d0 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -187,14 +187,10 @@ class SocketBuffer(object): # blocking error, simply return False indicating that # there's no data to be read. otherwise raise the # original exception. - allowed_errno = NONBLOCKING_EXCEPTION_ERROR_NUMBERS[ex.__class__] - if raise_on_timeout or ex.errno != allowed_errno: - raise - return False - except socket.timeout: - if raise_on_timeout: - raise - return False + allowed = NONBLOCKING_EXCEPTION_ERROR_NUMBERS.get(ex.__class__, -1) + if not raise_on_timeout and ex.errno == allowed: + return False + raise finally: if custom_timeout: sock.settimeout(self.socket_timeout) @@ -417,14 +413,10 @@ class HiredisParser(BaseParser): # blocking error, simply return False indicating that # there's no data to be read. otherwise raise the # original exception. - allowed_errno = NONBLOCKING_EXCEPTION_ERROR_NUMBERS[ex.__class__] - if raise_on_timeout or ex.errno != allowed_errno: - raise - return False - except socket.timeout: - if not raise_on_timeout: - raise - return False + allowed = NONBLOCKING_EXCEPTION_ERROR_NUMBERS.get(ex.__class__, -1) + if not raise_on_timeout and ex.errno == allowed: + return False + raise finally: if custom_timeout: sock.settimeout(self._socket_timeout) |