Skip to content

Commit ffc228d

Browse files
authored
gh-89745: Avoid exact match when comparing program_name in test_embed on Windows (GH-93888)
1 parent 4beee0c commit ffc228d

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

Lib/test/test_embed.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ def _get_expected_config(self):
629629
return configs
630630

631631
def get_expected_config(self, expected_preconfig, expected,
632-
env, api, modify_path_cb=None, cwd=None):
632+
env, api, modify_path_cb=None):
633633
configs = self._get_expected_config()
634634

635635
pre_config = configs['pre_config']
@@ -672,14 +672,6 @@ def get_expected_config(self, expected_preconfig, expected,
672672
expected['base_executable'] = default_executable
673673
if expected['program_name'] is self.GET_DEFAULT_CONFIG:
674674
expected['program_name'] = './_testembed'
675-
if MS_WINDOWS:
676-
# follow the calculation in getpath.py
677-
tmpname = expected['program_name'] + '.exe'
678-
if cwd:
679-
tmpname = os.path.join(cwd, tmpname)
680-
if os.path.isfile(tmpname):
681-
expected['program_name'] += '.exe'
682-
del tmpname
683675

684676
config = configs['config']
685677
for key, value in expected.items():
@@ -709,6 +701,11 @@ def check_pre_config(self, configs, expected):
709701

710702
def check_config(self, configs, expected):
711703
config = dict(configs['config'])
704+
if MS_WINDOWS:
705+
value = config.get(key := 'program_name')
706+
if value and isinstance(value, str):
707+
ext = '_d.exe' if debug_build(sys.executable) else '.exe'
708+
config[key] = value[:len(value.lower().removesuffix(ext))]
712709
for key, value in list(expected.items()):
713710
if value is self.IGNORE_CONFIG:
714711
config.pop(key, None)
@@ -773,7 +770,7 @@ def check_all_configs(self, testname, expected_config=None,
773770
self.get_expected_config(expected_preconfig,
774771
expected_config,
775772
env,
776-
api, modify_path_cb, cwd)
773+
api, modify_path_cb)
777774

778775
out, err = self.run_embedded_interpreter(testname,
779776
env=env, cwd=cwd)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy