Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
3000d975
Commit
3000d975
authored
Dec 28, 2016
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-introduce _iter_code functionality as a Bytecode backport. Fixes failing tests. Ref #866.
parent
a01cf3c2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
2 deletions
+49
-2
setuptools/depends.py
setuptools/depends.py
+3
-2
setuptools/py33compat.py
setuptools/py33compat.py
+46
-0
No files found.
setuptools/depends.py
View file @
3000d975
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
.py33compat
import
Bytecode
__all__
=
[
'Require'
,
'find_module'
,
'get_module_constant'
,
'extract_constant'
...
...
@@ -155,7 +156,7 @@ def extract_constant(code, symbol, default=-1):
const
=
default
for
byte_code
in
dis
.
Bytecode
(
code
):
for
byte_code
in
Bytecode
(
code
):
op
=
byte_code
.
opcode
arg
=
byte_code
.
arg
...
...
setuptools/py33compat.py
0 → 100644
View file @
3000d975
import
dis
import
code
import
array
import
collections
from
setuptools.extern
import
six
OpArg
=
collections
.
namedtuple
(
'OpArg'
,
'opcode arg'
)
class
Bytecode_compat
(
object
):
def
__init__
(
self
,
code
):
self
.
code
=
code
def
__iter__
(
self
):
"""Yield '(op,arg)' pair for each operation in code object 'code'"""
bytes
=
array
.
array
(
'b'
,
self
.
code
.
co_code
)
eof
=
len
(
self
.
code
.
co_code
)
ptr
=
0
extended_arg
=
0
while
ptr
<
eof
:
op
=
bytes
[
ptr
]
if
op
>=
dis
.
HAVE_ARGUMENT
:
arg
=
bytes
[
ptr
+
1
]
+
bytes
[
ptr
+
2
]
*
256
+
extended_arg
ptr
+=
3
if
op
==
dis
.
EXTENDED_ARG
:
long_type
=
six
.
integer_types
[
-
1
]
extended_arg
=
arg
*
long_type
(
65536
)
continue
else
:
arg
=
None
ptr
+=
1
yield
OpArg
(
op
,
arg
)
Bytecode
=
getattr
(
dis
,
'Bytecode'
,
Bytecode_compat
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment