mirror of
https://github.com/python/cpython.git
synced 2025-10-14 18:59:46 +00:00
Issue #23731: Implement PEP 488.
The concept of .pyo files no longer exists. Now .pyc files have an optional `opt-` tag which specifies if any extra optimizations beyond the peepholer were applied.
This commit is contained in:
parent
a63cc21234
commit
f299abdafa
56 changed files with 4731 additions and 4621 deletions
19
Lib/imp.py
19
Lib/imp.py
|
@ -58,24 +58,23 @@ def new_module(name):
|
|||
def get_magic():
|
||||
"""**DEPRECATED**
|
||||
|
||||
Return the magic number for .pyc or .pyo files.
|
||||
Return the magic number for .pyc files.
|
||||
"""
|
||||
return util.MAGIC_NUMBER
|
||||
|
||||
|
||||
def get_tag():
|
||||
"""Return the magic tag for .pyc or .pyo files."""
|
||||
"""Return the magic tag for .pyc files."""
|
||||
return sys.implementation.cache_tag
|
||||
|
||||
|
||||
def cache_from_source(path, debug_override=None):
|
||||
"""**DEPRECATED**
|
||||
|
||||
Given the path to a .py file, return the path to its .pyc/.pyo file.
|
||||
Given the path to a .py file, return the path to its .pyc file.
|
||||
|
||||
The .py file does not need to exist; this simply returns the path to the
|
||||
.pyc/.pyo file calculated as if the .py file were imported. The extension
|
||||
will be .pyc unless sys.flags.optimize is non-zero, then it will be .pyo.
|
||||
.pyc file calculated as if the .py file were imported.
|
||||
|
||||
If debug_override is not None, then it must be a boolean and is used in
|
||||
place of sys.flags.optimize.
|
||||
|
@ -83,16 +82,18 @@ def cache_from_source(path, debug_override=None):
|
|||
If sys.implementation.cache_tag is None then NotImplementedError is raised.
|
||||
|
||||
"""
|
||||
return util.cache_from_source(path, debug_override)
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore')
|
||||
return util.cache_from_source(path, debug_override)
|
||||
|
||||
|
||||
def source_from_cache(path):
|
||||
"""**DEPRECATED**
|
||||
|
||||
Given the path to a .pyc./.pyo file, return the path to its .py file.
|
||||
Given the path to a .pyc. file, return the path to its .py file.
|
||||
|
||||
The .pyc/.pyo file does not need to exist; this simply returns the path to
|
||||
the .py file calculated to correspond to the .pyc/.pyo file. If path does
|
||||
The .pyc file does not need to exist; this simply returns the path to
|
||||
the .py file calculated to correspond to the .pyc file. If path does
|
||||
not conform to PEP 3147 format, ValueError will be raised. If
|
||||
sys.implementation.cache_tag is None then NotImplementedError is raised.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue