@@ -181,7 +181,7 @@ def __init__(self, host="localhost", user=None, password="",
181181 '_pid' : str (os .getpid ()),
182182 '_client_version' : '0.0.16' ,
183183 }
184- if False or program_name :
184+ if program_name :
185185 self ._connect_attrs ["program_name" ] = program_name
186186 elif sys .argv :
187187 self ._connect_attrs ["program_name" ] = sys .argv [0 ]
@@ -738,12 +738,12 @@ async def _request_authentication(self):
738738
739739 self ._auth_plugin_used = auth_plugin
740740
741+ # Sends the server a few pieces of client info
741742 if self .server_capabilities & CLIENT .CONNECT_ATTRS :
742743 connect_attrs = b''
743744 for k , v in self ._connect_attrs .items ():
744- k = k .encode ('utf8' )
745+ k , v = k . encode ( 'utf8' ), v .encode ('utf8' )
745746 connect_attrs += struct .pack ('B' , len (k )) + k
746- v = v .encode ('utf8' )
747747 connect_attrs += struct .pack ('B' , len (v )) + v
748748 data += struct .pack ('B' , len (connect_attrs )) + connect_attrs
749749
@@ -759,15 +759,14 @@ async def _request_authentication(self):
759759 plugin_name = auth_packet .read_string ()
760760 if (self .server_capabilities & CLIENT .PLUGIN_AUTH and
761761 plugin_name is not None ):
762- auth_packet = await self ._process_auth (
763- plugin_name , auth_packet )
762+ await self ._process_auth (plugin_name , auth_packet )
764763 else :
765764 # send legacy handshake
766765 data = _auth .scramble_old_password (
767766 self ._password .encode ('latin1' ),
768767 auth_packet .read_all ()) + b'\0 '
769768 self .write_packet (data )
770- auth_packet = await self ._read_packet ()
769+ await self ._read_packet ()
771770
772771 async def _process_auth (self , plugin_name , auth_packet ):
773772 if plugin_name == b"mysql_native_password" :
0 commit comments