summaryrefslogtreecommitdiff
path: root/Lib/imp.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-07-02 15:13:11 -0400
committerBrett Cannon <brett@python.org>2012-07-02 15:13:11 -0400
commit80184ef410b1a602b43cd805a6b46aa98a6ca1ae (patch)
treee261b4ebb328b6d674d8758425ba7f3b2e214470 /Lib/imp.py
parente4b5846fa645edef3b0ce7f029bfc8c6cb3b1be6 (diff)
downloadcpython-80184ef410b1a602b43cd805a6b46aa98a6ca1ae.tar.gz
Issue #15166: Re-implement imp.get_tag() using sys.implementation.
Also eliminates some C code in Python/import.c as well. Patch by Eric Snow with verification by comparing against another patch from Jeff Knupp.
Diffstat (limited to 'Lib/imp.py')
-rw-r--r--Lib/imp.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/imp.py b/Lib/imp.py
index 8c89237f07..fcfd3d36ee 100644
--- a/Lib/imp.py
+++ b/Lib/imp.py
@@ -11,7 +11,7 @@ from _imp import (lock_held, acquire_lock, release_lock,
init_builtin, init_frozen, is_builtin, is_frozen,
_fix_co_filename, extension_suffixes)
# Could move out of _imp, but not worth the code
-from _imp import get_magic, get_tag
+from _imp import get_magic
from importlib._bootstrap import new_module
from importlib._bootstrap import cache_from_source
@@ -37,6 +37,11 @@ PY_CODERESOURCE = 8
IMP_HOOK = 9
+def get_tag():
+ """Return the magic tag for .pyc or .pyo files."""
+ return sys.implementation.cache_tag
+
+
def get_suffixes():
warnings.warn('imp.get_suffixes() is deprecated; use the constants '
'defined on importlib.machinery instead',