]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-124842: Fix test.support.import_helper.make_legacy_pyc() (GH-124843)
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 1 Oct 2024 16:05:17 +0000 (19:05 +0300)
committerGitHub <noreply@github.com>
Tue, 1 Oct 2024 16:05:17 +0000 (16:05 +0000)
For source file "path/to/file.py" it created file with incorrect path
"/absolute/path/to/path/to/file.pyc" instead of "path/to/file.pyc".

Lib/test/support/import_helper.py

index edcd2b9a35bbd9d48a31808f79165382430b66bb..2b91bdcf9cd8595cabdf1840cd6ff077019f2969 100644 (file)
@@ -58,8 +58,8 @@ def make_legacy_pyc(source):
     :return: The file system path to the legacy pyc file.
     """
     pyc_file = importlib.util.cache_from_source(source)
-    up_one = os.path.dirname(os.path.abspath(source))
-    legacy_pyc = os.path.join(up_one, source + 'c')
+    assert source.endswith('.py')
+    legacy_pyc = source + 'c'
     shutil.move(pyc_file, legacy_pyc)
     return legacy_pyc