cpython: 91467f342977 (original) (raw)
Mercurial > cpython
changeset 84147:91467f342977
Issue #17177: Stop using imp with py_compile [#17177]
Brett Cannon brett@python.org | |
---|---|
date | Sat, 15 Jun 2013 14:07:21 -0400 |
parents | acca81736b69 |
children | 81cf3d6e6756 |
files | Lib/py_compile.py Lib/test/test_py_compile.py |
diffstat | 2 files changed, 6 insertions(+), 5 deletions(-)[+] [-] Lib/py_compile.py 7 Lib/test/test_py_compile.py 4 |
line wrap: on
line diff
--- a/Lib/py_compile.py +++ b/Lib/py_compile.py @@ -3,9 +3,9 @@ This module has intimate knowledge of the format of .pyc files. """ -import imp import importlib._bootstrap import importlib.machinery +import importlib.util import os import os.path import sys @@ -105,9 +105,10 @@ def compile(file, cfile=None, dfile=None """ if cfile is None: if optimize >= 0:
cfile = imp.cache_from_source(file, debug_override=not optimize)[](#l1.18)
cfile = importlib.util.cache_from_source(file,[](#l1.19)
debug_override=not optimize)[](#l1.20) else:[](#l1.21)
cfile = imp.cache_from_source(file)[](#l1.22)
if os.path.islink(cfile): msg = ('{} is a symlink and will be changed into a regular file if ' 'import writes a byte-compiled file to it')cfile = importlib.util.cache_from_source(file)[](#l1.23)
--- a/Lib/test/test_py_compile.py +++ b/Lib/test/test_py_compile.py @@ -1,4 +1,4 @@ -import imp +import importlib.util import os import py_compile import shutil @@ -14,7 +14,7 @@ class PyCompileTests(unittest.TestCase): self.directory = tempfile.mkdtemp() self.source_path = os.path.join(self.directory, '_test.py') self.pyc_path = self.source_path + 'c'
self.cache_path = imp.cache_from_source(self.source_path)[](#l2.13)
self.cache_path = importlib.util.cache_from_source(self.source_path)[](#l2.14) self.cwd_drive = os.path.splitdrive(os.getcwd())[0][](#l2.15) # In these tests we compute relative paths. When using Windows, the[](#l2.16) # current working directory path and the 'self.source_path' might be[](#l2.17)