diff options
| author | Antoine Pitrou <solipsis@pitrou.net> | 2012-07-13 18:59:35 (GMT) |
|---|---|---|
| committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-07-13 18:59:35 (GMT) |
| commit | c287423cb02ab4f466191cfea1d038f857b7db5c (patch) | |
| tree | 8345d849442072c06a357798a3143e073303cc4e /Lib/imp.py | |
| parent | c27ace688c91c3e52f66c0ff4b4c00f674912943 (diff) | |
| parent | fb20a1a924bd847e23315e8e3983ebdea959913e (diff) | |
| download | cpython-c287423cb02ab4f466191cfea1d038f857b7db5c.zip cpython-c287423cb02ab4f466191cfea1d038f857b7db5c.tar.gz cpython-c287423cb02ab4f466191cfea1d038f857b7db5c.tar.bz2 | |
Merge
Diffstat (limited to 'Lib/imp.py')
| -rw-r--r-- | Lib/imp.py | 25 |
1 files changed, 1 insertions, 24 deletions
@@ -13,7 +13,7 @@ from _imp import (lock_held, acquire_lock, release_lock, # Directly exposed by this module from importlib._bootstrap import new_module -from importlib._bootstrap import cache_from_source +from importlib._bootstrap import cache_from_source, source_from_cache from importlib import _bootstrap @@ -58,29 +58,6 @@ def get_suffixes(): return extensions + source + bytecode -def source_from_cache(path): - """Given the path to a .pyc./.pyo 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 - not conform to PEP 3147 format, ValueError will be raised. If - sys.implementation.cache_tag is None then NotImplementedError is raised. - - """ - if sys.implementation.cache_tag is None: - raise NotImplementedError('sys.implementation.cache_tag is None') - head, pycache_filename = os.path.split(path) - head, pycache = os.path.split(head) - if pycache != _bootstrap._PYCACHE: - raise ValueError('{} not bottom-level directory in ' - '{!r}'.format(_bootstrap._PYCACHE, path)) - if pycache_filename.count('.') != 2: - raise ValueError('expected only 2 dots in ' - '{!r}'.format(pycache_filename)) - base_filename = pycache_filename.partition('.')[0] - return os.path.join(head, base_filename + machinery.SOURCE_SUFFIXES[0]) - - class NullImporter: """Null import object.""" |
