@@ -1454,7 +1454,7 @@ def get_python_argv(self):
14541454 return self .options .python_path
14551455 return [self .options .python_path ]
14561456
1457- def get_boot_command (self ):
1457+ def _first_stage_base64 (self ):
14581458 source = inspect .getsource (self ._first_stage )
14591459 source = textwrap .dedent ('\n ' .join (source .strip ().split ('\n ' )[2 :]))
14601460 source = source .replace (' ' , ' ' )
@@ -1464,17 +1464,23 @@ def get_boot_command(self):
14641464 str (len (preamble_compressed )))
14651465 compressed = zlib .compress (source .encode (), 9 )
14661466 encoded = binascii .b2a_base64 (compressed ).replace (b ('\n ' ), b ('' ))
1467+ return encoded .decode ('ascii' )
14671468
1469+ def _bootstrap_argv (self ):
14681470 # Just enough to decode, decompress, and exec the first stage.
14691471 # Priorities: wider compatibility, faster startup, shorter length.
14701472 # `import os` here, instead of stage 1, to save a few bytes.
14711473 # `sys.path=...` for https://github.com/python/cpython/issues/115911.
1472- return self . get_python_argv () + [
1474+ return [
14731475 '-c' ,
14741476 'import sys;sys.path=[p for p in sys.path if p];import binascii,os,zlib;'
1475- 'exec(zlib.decompress(binascii.a2b_base64("%s")))' % (encoded .decode (),),
1477+ 'exec(zlib.decompress(binascii.a2b_base64(sys.argv[1])))' ,
1478+ self ._first_stage_base64 (),
14761479 ]
14771480
1481+ def get_boot_command (self ):
1482+ return self .get_python_argv () + self ._bootstrap_argv ()
1483+
14781484 def get_econtext_config (self ):
14791485 assert self .options .max_message_size is not None
14801486 parent_ids = mitogen .parent_ids [:]
@@ -1510,7 +1516,7 @@ def _get_name(self):
15101516
15111517 def start_child (self ):
15121518 args = self .get_boot_command ()
1513- LOG .debug ('command line for %r: %s' , self , Argv ( args ) )
1519+ LOG .debug ('command line for %r: %s' , self , args )
15141520 try :
15151521 return self .create_child (args = args , ** self .create_child_args )
15161522 except OSError :
0 commit comments