From: Serhiy Storchaka Date: Tue, 1 Oct 2024 16:05:17 +0000 (+0300) Subject: gh-124842: Fix test.support.import_helper.make_legacy_pyc() (GH-124843) X-Git-Tag: v3.14.0a1~228 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=60ff67d010078eca15a74b1429caf779ac4f9c74;p=thirdparty%2FPython%2Fcpython.git gh-124842: Fix test.support.import_helper.make_legacy_pyc() (GH-124843) 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". --- diff --git a/Lib/test/support/import_helper.py b/Lib/test/support/import_helper.py index edcd2b9a35bb..2b91bdcf9cd8 100644 --- a/Lib/test/support/import_helper.py +++ b/Lib/test/support/import_helper.py @@ -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