summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_embed.py
diff options
context:
space:
mode:
authorneonene <53406459+neonene@users.noreply.github.com>2022-01-13 23:35:42 (GMT)
committerGitHub <noreply@github.com>2022-01-13 23:35:42 (GMT)
commitd4e64cd4b0ea431d4e371f9b0a25f6b75a069dc1 (patch)
treececdf1d08cb790283d061b8263086354976c4939 /Lib/test/test_embed.py
parentb8ddf7e794e5316981016d6d014862e3c4ce149a (diff)
downloadcpython-d4e64cd4b0ea431d4e371f9b0a25f6b75a069dc1.zip
cpython-d4e64cd4b0ea431d4e371f9b0a25f6b75a069dc1.tar.gz
cpython-d4e64cd4b0ea431d4e371f9b0a25f6b75a069dc1.tar.bz2
bpo-46362: Ensure ntpath.abspath() uses the Windows API correctly (GH-30571)
This makes ntpath.abspath()/getpath_abspath() follow normpath(), since some WinAPIs such as PathCchSkipRoot() require backslashed paths.
Diffstat (limited to 'Lib/test/test_embed.py')
-rw-r--r--Lib/test/test_embed.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py
index dd43669..02bbe35 100644
--- a/Lib/test/test_embed.py
+++ b/Lib/test/test_embed.py
@@ -1404,6 +1404,33 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
api=API_COMPAT, env=env,
ignore_stderr=True, cwd=tmpdir)
+ @unittest.skipUnless(MS_WINDOWS, 'specific to Windows')
+ def test_getpath_abspath_win32(self):
+ # Check _Py_abspath() is passed a backslashed path not to fall back to
+ # GetFullPathNameW() on startup, which (re-)normalizes the path overly.
+ # Currently, _Py_normpath() doesn't trim trailing dots and spaces.
+ CASES = [
+ ("C:/a. . .", "C:\\a. . ."),
+ ("C:\\a. . .", "C:\\a. . ."),
+ ("\\\\?\\C:////a////b. . .", "\\\\?\\C:\\a\\b. . ."),
+ ("//a/b/c. . .", "\\\\a\\b\\c. . ."),
+ ("\\\\a\\b\\c. . .", "\\\\a\\b\\c. . ."),
+ ("a. . .", f"{os.getcwd()}\\a"), # relpath gets fully normalized
+ ]
+ out, err = self.run_embedded_interpreter(
+ "test_init_initialize_config",
+ env=dict(PYTHONPATH=os.path.pathsep.join(c[0] for c in CASES))
+ )
+ self.assertEqual(err, "")
+ try:
+ out = json.loads(out)
+ except json.JSONDecodeError:
+ self.fail(f"fail to decode stdout: {out!r}")
+
+ results = out['config']["module_search_paths"]
+ for (_, expected), result in zip(CASES, results):
+ self.assertEqual(result, expected)
+
def test_global_pathconfig(self):
# Test C API functions getting the path configuration:
#