Skip to content

Commit 0e7f7af

Browse files
committed
Hide deprecation warnings from imp, like e.g.
python 3.7 does it (https://github.com/python/cpython/blob/3.7/Lib/modulefinder.py)
1 parent 9615fc8 commit 0e7f7af

File tree

1 file changed

+5
-61
lines changed

1 file changed

+5
-61
lines changed

pydeps/mf27.py

Lines changed: 5 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11

22
# from .mf.mf_next import * # for debugging next version
33
from modulefinder import (
4-
# STORE_OPS,
5-
# LOAD_CONST,
6-
# IMPORT_NAME,
74
ModuleFinder as NativeModuleFinder
85
)
9-
# import struct
10-
import imp
6+
import warnings
7+
with warnings.catch_warnings():
8+
warnings.simplefilter('ignore', PendingDeprecationWarning)
9+
import imp
1110
import marshal
1211
import dis
13-
# import sys
12+
1413
HAVE_ARGUMENT = dis.HAVE_ARGUMENT
1514

1615

@@ -77,61 +76,6 @@ def load_module(self, fqname, fp, pathname, file_info):
7776
self.msgout(2, "load_module ->", m)
7877
return m
7978

80-
# def scan_opcodes_24(self, co,
81-
# unpack=struct.unpack): # pragma: nocover
82-
# # Scan the code, and yield 'interesting' opcode combinations
83-
# # Version for Python 2.4 and older
84-
# code = co.co_code
85-
# names = co.co_names
86-
# consts = co.co_consts
87-
# while code:
88-
# c = code[0]
89-
# if c in STORE_OPS:
90-
# oparg, = unpack('<H', code[1:3])
91-
# yield "store", (names[oparg],)
92-
# code = code[3:]
93-
# continue
94-
# if c == LOAD_CONST and code[3] == IMPORT_NAME:
95-
# oparg_1, oparg_2 = unpack('<xHxH', code[:6])
96-
# yield "import", (consts[oparg_1], names[oparg_2])
97-
# code = code[6:]
98-
# continue
99-
# if c >= HAVE_ARGUMENT:
100-
# code = code[3:]
101-
# else:
102-
# code = code[1:]
103-
104-
# def scan_opcodes_25(self, co,
105-
# unpack = struct.unpack):
106-
# # Scan the code, and yield 'interesting' opcode combinations
107-
# # Python 2.5 version (has absolute and relative imports)
108-
# code = co.co_code
109-
# names = co.co_names
110-
# consts = co.co_consts
111-
# LOAD_LOAD_AND_IMPORT = LOAD_CONST + LOAD_CONST + IMPORT_NAME
112-
# while code:
113-
# c = code[0]
114-
# if c in STORE_OPS:
115-
# oparg, = unpack('<H', code[1:3])
116-
# yield "store", (names[oparg],)
117-
# code = code[3:]
118-
# continue
119-
# if code[:9:3] == LOAD_LOAD_AND_IMPORT:
120-
# oparg_1, oparg_2, oparg_3 = unpack('<xHxHxH', code[:9])
121-
# level = consts[oparg_1]
122-
# if level == -1: # normal import
123-
# yield "import", (consts[oparg_2], names[oparg_3])
124-
# elif level == 0: # absolute import
125-
# yield "absolute_import", (consts[oparg_2], names[oparg_3])
126-
# else: # relative import
127-
# yield "relative_import", (level, consts[oparg_2], names[oparg_3])
128-
# code = code[9:]
129-
# continue
130-
# if c >= HAVE_ARGUMENT:
131-
# code = code[3:]
132-
# else:
133-
# code = code[1:]
134-
13579
def scan_code(self, co, m):
13680
code = co.co_code # noqa
13781
# if sys.version_info >= (3, 4):

0 commit comments

Comments
 (0)