summaryrefslogtreecommitdiff
path: root/setuptools/depends.py
diff options
context:
space:
mode:
Diffstat (limited to 'setuptools/depends.py')
-rw-r--r--setuptools/depends.py16
1 files changed, 5 insertions, 11 deletions
diff --git a/setuptools/depends.py b/setuptools/depends.py
index c150c52b..d417fa32 100644
--- a/setuptools/depends.py
+++ b/setuptools/depends.py
@@ -5,6 +5,7 @@ import dis
from distutils.version import StrictVersion
from imp import PKG_DIRECTORY, PY_COMPILED, PY_SOURCE, PY_FROZEN
+
__all__ = [
'Require', 'find_module', 'get_module_constant', 'extract_constant'
]
@@ -77,14 +78,6 @@ class Require:
return self.version_ok(version)
-def _iter_code(code):
- """Yield '(op,arg)' pair for each operation in code object 'code'"""
- return (
- (op.opcode, op.arg)
- for op in dis.Bytecode(code)
- )
-
-
def find_module(module, paths=None):
"""Just like 'imp.find_module()', but with package support"""
@@ -150,9 +143,8 @@ def extract_constant(code, symbol, default=-1):
only 'STORE_NAME' and 'STORE_GLOBAL' opcodes are checked, and 'symbol'
must be present in 'code.co_names'.
"""
-
if symbol not in code.co_names:
- # name's not there, can't possibly be an assigment
+ # name's not there, can't possibly be an assignment
return None
name_idx = list(code.co_names).index(symbol)
@@ -163,7 +155,9 @@ def extract_constant(code, symbol, default=-1):
const = default
- for op, arg in _iter_code(code):
+ for byte_code in dis.Bytecode(code):
+ op = byte_code.opcode
+ arg = byte_code.arg
if op == LOAD_CONST:
const = code.co_consts[arg]