]> granicus.if.org Git - python/commitdiff
Issue #17177: Stop using imp in zipfile
authorBrett Cannon <brett@python.org>
Sat, 15 Jun 2013 21:32:30 +0000 (17:32 -0400)
committerBrett Cannon <brett@python.org>
Sat, 15 Jun 2013 21:32:30 +0000 (17:32 -0400)
Lib/test/test_zipfile.py
Lib/zipfile.py

index 188a3077e1be29f71210bdb7c34855c88e1d3a66..d3a359f06632a513855599c758329fbb13ff9b2d 100644 (file)
@@ -1,7 +1,7 @@
 import io
 import os
 import sys
-import imp
+import importlib.util
 import time
 import shutil
 import struct
@@ -869,7 +869,7 @@ class PyZipFileTests(unittest.TestCase):
                 if os.altsep is not None:
                     path_split.extend(fn.split(os.altsep))
                 if '__pycache__' in path_split:
-                    fn = imp.source_from_cache(fn)
+                    fn = importlib.util.source_from_cache(fn)
                 else:
                     fn = fn[:-1]
 
index adaffe1e9234b531e5997c975059866671de7e3f..4099930b339fe35475443ba9a74305c02f647214 100644 (file)
@@ -6,7 +6,7 @@ XXX references to utf-8 need further investigation.
 import io
 import os
 import re
-import imp
+import importlib.util
 import sys
 import time
 import stat
@@ -1645,8 +1645,8 @@ class PyZipFile(ZipFile):
         file_py  = pathname + ".py"
         file_pyc = pathname + ".pyc"
         file_pyo = pathname + ".pyo"
-        pycache_pyc = imp.cache_from_source(file_py, True)
-        pycache_pyo = imp.cache_from_source(file_py, False)
+        pycache_pyc = importlib.util.cache_from_source(file_py, True)
+        pycache_pyo = importlib.util.cache_from_source(file_py, False)
         if self._optimize == -1:
             # legacy mode: use whatever file is present
             if (os.path.isfile(file_pyo) and