Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b57a085

Browse files
committed
Issue #17177: Stop using imp in zipfile
1 parent 9529fbf commit b57a085

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

Lib/test/test_zipfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import io
22
import os
33
import sys
4-
import imp
4+
import importlib.util
55
import time
66
import shutil
77
import struct
@@ -869,7 +869,7 @@ def test_write_pyfile(self):
869869
if os.altsep is not None:
870870
path_split.extend(fn.split(os.altsep))
871871
if '__pycache__' in path_split:
872-
fn = imp.source_from_cache(fn)
872+
fn = importlib.util.source_from_cache(fn)
873873
else:
874874
fn = fn[:-1]
875875

Lib/zipfile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import io
77
import os
88
import re
9-
import imp
9+
import importlib.util
1010
import sys
1111
import time
1212
import stat
@@ -1645,8 +1645,8 @@ def _compile(file, optimize=-1):
16451645
file_py = pathname + ".py"
16461646
file_pyc = pathname + ".pyc"
16471647
file_pyo = pathname + ".pyo"
1648-
pycache_pyc = imp.cache_from_source(file_py, True)
1649-
pycache_pyo = imp.cache_from_source(file_py, False)
1648+
pycache_pyc = importlib.util.cache_from_source(file_py, True)
1649+
pycache_pyo = importlib.util.cache_from_source(file_py, False)
16501650
if self._optimize == -1:
16511651
# legacy mode: use whatever file is present
16521652
if (os.path.isfile(file_pyo) and

0 commit comments

Comments
 (0)