MCPcopy Index your code
hub / github.com/python/cpython / make_legacy_pyc

Function make_legacy_pyc

Lib/test/support/import_helper.py:59–78  ·  view source on GitHub ↗

Move a PEP 3147/488 pyc file to its legacy pyc location. :param source: The file system path to the source file. The source file does not need to exist, however the PEP 3147/488 pyc file must exist or allow_compile must be set. :param allow_compile: If True, uses py_compile

(source, allow_compile=False)

Source from the content-addressed store, hash-verified

57
58
59def make_legacy_pyc(source, allow_compile=False):
60 """Move a PEP 3147/488 pyc file to its legacy pyc location.
61
62 :param source: The file system path to the source file. The source file
63 does not need to exist, however the PEP 3147/488 pyc file must exist or
64 allow_compile must be set.
65 :param allow_compile: If True, uses py_compile to create a .pyc if it does
66 not exist. This should be passed as True if cache_tag may be None.
67 :return: The file system path to the legacy pyc file.
68 """
69 assert source.endswith('.py')
70 legacy_pyc = source + 'c'
71 try:
72 pyc_file = importlib.util.cache_from_source(source)
73 shutil.move(pyc_file, legacy_pyc)
74 except FileNotFoundError, NotImplementedError:
75 if not allow_compile:
76 raise
77 py_compile.compile(source, legacy_pyc, doraise=True)
78 return legacy_pyc
79
80
81def import_module(name, deprecated=False, *, required_on=()):

Callers 10

_check_moduleMethod · 0.90
_check_packageMethod · 0.90
manipulate_bytecodeMethod · 0.90
run_testMethod · 0.90
test_file_to_sourceMethod · 0.90
make_zip_scriptFunction · 0.90

Calls 3

endswithMethod · 0.45
moveMethod · 0.45
compileMethod · 0.45

Tested by 9

_check_moduleMethod · 0.72
_check_packageMethod · 0.72
manipulate_bytecodeMethod · 0.72
run_testMethod · 0.72
test_file_to_sourceMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…