@@ -315,7 +315,7 @@ def on_disconnect(self):
315315 def can_read (self , timeout ):
316316 return self ._buffer and self ._buffer .can_read (timeout )
317317
318- def read_response (self ):
318+ def read_response (self , disable_decoding = False ):
319319 raw = self ._buffer .readline ()
320320 if not raw :
321321 raise ConnectionError (SERVER_CLOSED_CONNECTION_ERROR )
@@ -355,8 +355,9 @@ def read_response(self):
355355 length = int (response )
356356 if length == - 1 :
357357 return None
358- response = [self .read_response () for i in range (length )]
359- if isinstance (response , bytes ):
358+ response = [self .read_response (disable_decoding = disable_decoding )
359+ for i in range (length )]
360+ if isinstance (response , bytes ) and disable_decoding is False :
360361 response = self .encoder .decode (response )
361362 return response
362363
@@ -450,7 +451,7 @@ def read_from_socket(self, timeout=SENTINEL, raise_on_timeout=True):
450451 if custom_timeout :
451452 sock .settimeout (self ._socket_timeout )
452453
453- def read_response (self ):
454+ def read_response (self , disable_decoding = False ):
454455 if not self ._reader :
455456 raise ConnectionError (SERVER_CLOSED_CONNECTION_ERROR )
456457
@@ -758,10 +759,12 @@ def can_read(self, timeout=0):
758759 self .connect ()
759760 return self ._parser .can_read (timeout )
760761
761- def read_response (self ):
762+ def read_response (self , disable_decoding = False ):
762763 """Read the response from a previously sent command"""
763764 try :
764- response = self ._parser .read_response ()
765+ response = self ._parser .read_response (
766+ disable_decoding = disable_decoding
767+ )
765768 except socket .timeout :
766769 self .disconnect ()
767770 raise TimeoutError ("Timeout reading from %s:%s" %
0 commit comments