From a027fd6266b2b50e0a4c148bfac00c3375db1eb4 Mon Sep 17 00:00:00 2001 From: Andy McCurdy Date: Mon, 21 Jul 2014 11:25:03 -0700 Subject: [PATCH] bytearray didn't work with socket.recv_into in python 2.6 --- redis/connection.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/redis/connection.py b/redis/connection.py index 7dc7a2fc8b..eb3fba41c4 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -44,13 +44,12 @@ "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('$')