@@ -181,7 +181,7 @@ def __init__(self, host="localhost", user=None, password="",
181
181
'_pid' : str (os .getpid ()),
182
182
'_client_version' : '0.0.16' ,
183
183
}
184
- if False or program_name :
184
+ if program_name :
185
185
self ._connect_attrs ["program_name" ] = program_name
186
186
elif sys .argv :
187
187
self ._connect_attrs ["program_name" ] = sys .argv [0 ]
@@ -738,12 +738,12 @@ async def _request_authentication(self):
738
738
739
739
self ._auth_plugin_used = auth_plugin
740
740
741
+ # Sends the server a few pieces of client info
741
742
if self .server_capabilities & CLIENT .CONNECT_ATTRS :
742
743
connect_attrs = b''
743
744
for k , v in self ._connect_attrs .items ():
744
- k = k .encode ('utf8' )
745
+ k , v = k . encode ( 'utf8' ), v .encode ('utf8' )
745
746
connect_attrs += struct .pack ('B' , len (k )) + k
746
- v = v .encode ('utf8' )
747
747
connect_attrs += struct .pack ('B' , len (v )) + v
748
748
data += struct .pack ('B' , len (connect_attrs )) + connect_attrs
749
749
@@ -759,15 +759,14 @@ async def _request_authentication(self):
759
759
plugin_name = auth_packet .read_string ()
760
760
if (self .server_capabilities & CLIENT .PLUGIN_AUTH and
761
761
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 )
764
763
else :
765
764
# send legacy handshake
766
765
data = _auth .scramble_old_password (
767
766
self ._password .encode ('latin1' ),
768
767
auth_packet .read_all ()) + b'\0 '
769
768
self .write_packet (data )
770
- auth_packet = await self ._read_packet ()
769
+ await self ._read_packet ()
771
770
772
771
async def _process_auth (self , plugin_name , auth_packet ):
773
772
if plugin_name == b"mysql_native_password" :
0 commit comments