bpo-37369: Fix initialization of sys members when launched via an app container (GH-14428)
sys._base_executable is now always defined on all platforms, and can be overridden through configuration.
Also adds test.support.PythonSymlink to encapsulate platform-specific logic for symlinking sys.executable
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py
index b897489..9c78aa0 100644
--- a/Lib/test/test_embed.py
+++ b/Lib/test/test_embed.py
@@ -362,6 +362,7 @@
'pythonpath_env': None,
'home': None,
'executable': GET_DEFAULT_CONFIG,
+ 'base_executable': GET_DEFAULT_CONFIG,
'prefix': GET_DEFAULT_CONFIG,
'base_prefix': GET_DEFAULT_CONFIG,
@@ -534,14 +535,16 @@
if expected['stdio_errors'] is self.GET_DEFAULT_CONFIG:
expected['stdio_errors'] = 'surrogateescape'
+ if sys.platform == 'win32':
+ default_executable = self.test_exe
+ elif expected['program_name'] is not self.GET_DEFAULT_CONFIG:
+ default_executable = os.path.abspath(expected['program_name'])
+ else:
+ default_executable = os.path.join(os.getcwd(), '_testembed')
if expected['executable'] is self.GET_DEFAULT_CONFIG:
- if sys.platform == 'win32':
- expected['executable'] = self.test_exe
- else:
- if expected['program_name'] is not self.GET_DEFAULT_CONFIG:
- expected['executable'] = os.path.abspath(expected['program_name'])
- else:
- expected['executable'] = os.path.join(os.getcwd(), '_testembed')
+ expected['executable'] = default_executable
+ if expected['base_executable'] is self.GET_DEFAULT_CONFIG:
+ expected['base_executable'] = default_executable
if expected['program_name'] is self.GET_DEFAULT_CONFIG:
expected['program_name'] = './_testembed'