3939from struct import pack as struct_pack , unpack as struct_unpack , unpack_from as struct_unpack_from
4040
4141from .constants import DEFAULT_USER_AGENT , KNOWN_HOSTS , MAGIC_PREAMBLE , TRUST_DEFAULT , TRUST_ON_FIRST_USE
42- from .compat import hex2
4342from .exceptions import ProtocolError , Unauthorized
4443from .packstream import Packer , Unpacker
4544from .ssl_compat import SSL_AVAILABLE , HAS_SNI , SSLError
@@ -137,7 +136,7 @@ def send(self):
137136 """
138137 data = self .raw .getvalue ()
139138 if __debug__ :
140- log_debug ("C: %s " , ":" . join ( map ( hex2 , data )) )
139+ log_debug ("C: b%r " , data )
141140 self .socket .sendall (data )
142141
143142 self .raw .seek (self .raw .truncate (0 ))
@@ -150,7 +149,7 @@ def _recv(self, size):
150149 # Read up to the required amount remaining
151150 b = self .socket .recv (8192 )
152151 if b :
153- if __debug__ : log_debug ("S: %s " , ":" . join ( map ( hex2 , b )) )
152+ if __debug__ : log_debug ("S: b%r " , b )
154153 else :
155154 if ready_to_read is not None :
156155 raise ProtocolError ("Server closed connection" )
@@ -454,7 +453,7 @@ def connect(host_port, ssl_context=None, **config):
454453 handshake = [MAGIC_PREAMBLE ] + supported_versions
455454 if __debug__ : log_info ("C: [HANDSHAKE] 0x%X %r" , MAGIC_PREAMBLE , supported_versions )
456455 data = b"" .join (struct_pack (">I" , num ) for num in handshake )
457- if __debug__ : log_debug ("C: %s " , ":" . join ( map ( hex2 , data )) )
456+ if __debug__ : log_debug ("C: b%r " , data )
458457 s .sendall (data )
459458
460459 # Handle the handshake response
@@ -469,7 +468,7 @@ def connect(host_port, ssl_context=None, **config):
469468 log_error ("S: [CLOSE]" )
470469 raise ProtocolError ("Server closed connection without responding to handshake" )
471470 if data_size == 4 :
472- if __debug__ : log_debug ("S: %s " , ":" . join ( map ( hex2 , data )) )
471+ if __debug__ : log_debug ("S: b%r " , data )
473472 else :
474473 # Some other garbled data has been received
475474 log_error ("S: @*#!" )
0 commit comments