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".
This commit is contained in:
Serhiy Storchaka 2024-10-01 19:05:17 +03:00 committed by GitHub
parent da1e5526ae
commit 60ff67d010
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View 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