File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -387,13 +387,13 @@ def get_exec_path(env=None):
387387
388388 try :
389389 path_list = env .get ('PATH' )
390- except TypeError :
390+ except ( TypeError , BytesWarning ) :
391391 path_list = None
392392
393393 if supports_bytes_environ :
394394 try :
395395 path_listb = env [b'PATH' ]
396- except (KeyError , TypeError ):
396+ except (KeyError , TypeError , BytesWarning ):
397397 pass
398398 else :
399399 if path_list is not None :
Original file line number Diff line number Diff line change @@ -450,8 +450,12 @@ def test_get_exec_path(self):
450450
451451 if os .supports_bytes_environ :
452452 # env cannot contain 'PATH' and b'PATH' keys
453- self .assertRaises (ValueError ,
454- os .get_exec_path , {'PATH' : '1' , b'PATH' : b'2' })
453+ try :
454+ mixed_env = {'PATH' : '1' , b'PATH' : b'2' }
455+ except BytesWarning :
456+ pass
457+ else :
458+ self .assertRaises (ValueError , os .get_exec_path , mixed_env )
455459
456460 # bytes key and/or value
457461 self .assertSequenceEqual (os .get_exec_path ({b'PATH' : b'abc' }),
@@ -723,7 +727,10 @@ def _test_internal_execvpe(self, test_type):
723727 # os.get_exec_path() reads the 'PATH' variable
724728 with _execvpe_mockup () as calls :
725729 env_path = env .copy ()
726- env_path ['PATH' ] = program_path
730+ if test_type is bytes :
731+ env_path [b'PATH' ] = program_path
732+ else :
733+ env_path ['PATH' ] = program_path
727734 self .assertRaises (OSError ,
728735 os ._execvpe , program , arguments , env = env_path )
729736 self .assertEqual (len (calls ), 1 )
You can’t perform that action at this time.
0 commit comments