Kaydet (Commit) b57a085c authored tarafından Brett Cannon's avatar Brett Cannon

Issue #17177: Stop using imp in zipfile

üst 9529fbfd
import io import io
import os import os
import sys import sys
import imp import importlib.util
import time import time
import shutil import shutil
import struct import struct
...@@ -869,7 +869,7 @@ class PyZipFileTests(unittest.TestCase): ...@@ -869,7 +869,7 @@ class PyZipFileTests(unittest.TestCase):
if os.altsep is not None: if os.altsep is not None:
path_split.extend(fn.split(os.altsep)) path_split.extend(fn.split(os.altsep))
if '__pycache__' in path_split: if '__pycache__' in path_split:
fn = imp.source_from_cache(fn) fn = importlib.util.source_from_cache(fn)
else: else:
fn = fn[:-1] fn = fn[:-1]
......
...@@ -6,7 +6,7 @@ XXX references to utf-8 need further investigation. ...@@ -6,7 +6,7 @@ XXX references to utf-8 need further investigation.
import io import io
import os import os
import re import re
import imp import importlib.util
import sys import sys
import time import time
import stat import stat
...@@ -1645,8 +1645,8 @@ class PyZipFile(ZipFile): ...@@ -1645,8 +1645,8 @@ class PyZipFile(ZipFile):
file_py = pathname + ".py" file_py = pathname + ".py"
file_pyc = pathname + ".pyc" file_pyc = pathname + ".pyc"
file_pyo = pathname + ".pyo" file_pyo = pathname + ".pyo"
pycache_pyc = imp.cache_from_source(file_py, True) pycache_pyc = importlib.util.cache_from_source(file_py, True)
pycache_pyo = imp.cache_from_source(file_py, False) pycache_pyo = importlib.util.cache_from_source(file_py, False)
if self._optimize == -1: if self._optimize == -1:
# legacy mode: use whatever file is present # legacy mode: use whatever file is present
if (os.path.isfile(file_pyo) and if (os.path.isfile(file_pyo) and
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment