FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-45582: Fix getpath_isxfile() and test_embed on Windows by neonene · Pull Request #29930 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .py  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
12 changes: 10 additions & 2 deletions Lib/test/test_embed.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def _get_expected_config(self):
return configs

def get_expected_config(self, expected_preconfig, expected,
env, api, modify_path_cb=None):
env, api, modify_path_cb=None, cwd=None):
configs = self._get_expected_config()

pre_config = configs['pre_config']
Expand Down Expand Up @@ -618,6 +618,14 @@ def get_expected_config(self, expected_preconfig, expected,
expected['base_executable'] = default_executable
if expected['program_name'] is self.GET_DEFAULT_CONFIG:
expected['program_name'] = './_testembed'
if MS_WINDOWS:
# follow the calculation in getpath.py
tmpname = expected['program_name'] + '.exe'
if cwd:
tmpname = os.path.join(cwd, tmpname)
if os.path.isfile(tmpname):
expected['program_name'] += '.exe'
del tmpname

config = configs['config']
for key, value in expected.items():
Expand Down Expand Up @@ -711,7 +719,7 @@ def check_all_configs(self, testname, expected_config=None,
self.get_expected_config(expected_preconfig,
expected_config,
env,
api, modify_path_cb)
api, modify_path_cb, cwd)

out, err = self.run_embedded_interpreter(testname,
env=env, cwd=cwd)
Expand Down
2 changes: 1 addition & 1 deletion Modules/getpath.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ getpath_isxfile(PyObject *Py_UNUSED(self), PyObject *args)
DWORD attr = GetFileAttributesW(path);
r = (attr != INVALID_FILE_ATTRIBUTES) &&
!(attr & FILE_ATTRIBUTE_DIRECTORY) &&
SUCCEEDED(PathCchFindExtension(path, cchPath, &ext)) &&
SUCCEEDED(PathCchFindExtension(path, cchPath + 1, &ext)) &&
(CompareStringOrdinal(ext, -1, L".exe", -1, 1 /* ignore case */) == CSTR_EQUAL)
? Py_True : Py_False;
#else
Expand Down

Back | FazBrowse Home | New Git URL