aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/depends.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-12-28 20:10:39 -0500
committerJason R. Coombs <jaraco@jaraco.com>2016-12-28 20:19:58 -0500
commita29c9a4de0c8cf75b89582a0bf718056d58b0c10 (patch)
tree8f62bc3c593964b71c74ce1b6994593d16c75e6d /setuptools/depends.py
parentb911a237e03a3892f423f3d5e2ec0caad1986b8d (diff)
downloadexternal_python_setuptools-a29c9a4de0c8cf75b89582a0bf718056d58b0c10.tar.gz
external_python_setuptools-a29c9a4de0c8cf75b89582a0bf718056d58b0c10.tar.bz2
external_python_setuptools-a29c9a4de0c8cf75b89582a0bf718056d58b0c10.zip
Use dis module rather than manually disassembling the bytecode. Fixes #866.
Diffstat (limited to 'setuptools/depends.py')
-rw-r--r--setuptools/depends.py36
1 files changed, 5 insertions, 31 deletions
diff --git a/setuptools/depends.py b/setuptools/depends.py
index 89d39a50..c150c52b 100644
--- a/setuptools/depends.py
+++ b/setuptools/depends.py
@@ -1,11 +1,10 @@
import sys
import imp
import marshal
+import dis
from distutils.version import StrictVersion
from imp import PKG_DIRECTORY, PY_COMPILED, PY_SOURCE, PY_FROZEN
-from setuptools.extern import six
-
__all__ = [
'Require', 'find_module', 'get_module_constant', 'extract_constant'
]
@@ -80,35 +79,10 @@ class Require:
def _iter_code(code):
"""Yield '(op,arg)' pair for each operation in code object 'code'"""
-
- from array import array
- from dis import HAVE_ARGUMENT, EXTENDED_ARG
-
- bytes = array('b', code.co_code)
- eof = len(code.co_code)
-
- ptr = 0
- extended_arg = 0
-
- while ptr < eof:
-
- op = bytes[ptr]
-
- if op >= HAVE_ARGUMENT:
-
- arg = bytes[ptr + 1] + bytes[ptr + 2] * 256 + extended_arg
- ptr += 3
-
- if op == EXTENDED_ARG:
- long_type = six.integer_types[-1]
- extended_arg = arg * long_type(65536)
- continue
-
- else:
- arg = None
- ptr += 1
-
- yield op, arg
+ return (
+ (op.opcode, op.arg)
+ for op in dis.Bytecode(code)
+ )
def find_module(module, paths=None):