diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2014-07-21 11:25:03 -0700 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2014-07-21 11:25:03 -0700 |
commit | a027fd6266b2b50e0a4c148bfac00c3375db1eb4 (patch) | |
tree | 5bdfafc1def1672ec37468a66d8ab0f2d76ca191 | |
parent | e0de592e9f923171f25117501eb52dbb595da995 (diff) | |
download | redis-py-a027fd6266b2b50e0a4c148bfac00c3375db1eb4.tar.gz |
bytearray didn't work with socket.recv_into in python 2.6
-rwxr-xr-x | redis/connection.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/redis/connection.py b/redis/connection.py index 7dc7a2f..eb3fba4 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -44,13 +44,12 @@ if HIREDIS_AVAILABLE: "hiredis %s. Please consider upgrading." % hiredis.__version__) warnings.warn(msg) - HIREDIS_USE_BYTE_BUFFER = False - if HIREDIS_SUPPORTS_BYTE_BUFFER: - try: - bytearray - HIREDIS_USE_BYTE_BUFFER = True - except NameError: - pass + HIREDIS_USE_BYTE_BUFFER = True + # only use byte buffer if hiredis supports it and the Python version + # is >= 2.7 + if not HIREDIS_SUPPORTS_BYTE_BUFFER or ( + sys.version_info[0] == 2 and sys.version_info[1] < 7): + HIREDIS_USE_BYTE_BUFFER = False SYM_STAR = b('*') SYM_DOLLAR = b('$') |