summaryrefslogtreecommitdiffstats
path: root/Lib/compileall.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2013-06-15 03:04:02 (GMT)
committerBrett Cannon <brett@python.org>2013-06-15 03:04:02 (GMT)
commit7822e123c42b63c5819e0b6cca6f960b1ce55547 (patch)
treeb904cf544553e36403b4a053b14eb73c590c418f /Lib/compileall.py
parent0b16b0d3f0b707a0558c41dd4c88c9465edbf434 (diff)
downloadcpython-7822e123c42b63c5819e0b6cca6f960b1ce55547.zip
cpython-7822e123c42b63c5819e0b6cca6f960b1ce55547.tar.gz
cpython-7822e123c42b63c5819e0b6cca6f960b1ce55547.tar.bz2
Issue #17177: stop using imp for compileall.
Diffstat (limited to 'Lib/compileall.py')
-rw-r--r--Lib/compileall.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/Lib/compileall.py b/Lib/compileall.py
index a8e9a31..475dc1c 100644
--- a/Lib/compileall.py
+++ b/Lib/compileall.py
@@ -13,7 +13,7 @@ See module py_compile for details of the actual byte-compilation.
import os
import sys
import errno
-import imp
+import importlib.util
import py_compile
import struct
@@ -91,17 +91,18 @@ def compile_file(fullname, ddir=None, force=False, rx=None, quiet=False,
cfile = fullname + ('c' if __debug__ else 'o')
else:
if optimize >= 0:
- cfile = imp.cache_from_source(fullname,
- debug_override=not optimize)
+ cfile = importlib.util.cache_from_source(
+ fullname, debug_override=not optimize)
else:
- cfile = imp.cache_from_source(fullname)
+ cfile = importlib.util.cache_from_source(fullname)
cache_dir = os.path.dirname(cfile)
head, tail = name[:-3], name[-3:]
if tail == '.py':
if not force:
try:
mtime = int(os.stat(fullname).st_mtime)
- expect = struct.pack('<4sl', imp.get_magic(), mtime)
+ expect = struct.pack('<4sl', importlib.util.MAGIC_NUMBER,
+ mtime)
with open(cfile, 'rb') as chandle:
actual = chandle.read(8)
if expect == actual: