mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
Patch #1739696: use code.co_code only if really necessary
This commit is contained in:
parent
f91149e4a1
commit
bc5fbd9f8c
1 changed files with 3 additions and 4 deletions
|
|
@ -679,7 +679,6 @@ def getargs(co):
|
||||||
if not iscode(co):
|
if not iscode(co):
|
||||||
raise TypeError('arg is not a code object')
|
raise TypeError('arg is not a code object')
|
||||||
|
|
||||||
code = co.co_code
|
|
||||||
nargs = co.co_argcount
|
nargs = co.co_argcount
|
||||||
names = co.co_varnames
|
names = co.co_varnames
|
||||||
args = list(names[:nargs])
|
args = list(names[:nargs])
|
||||||
|
|
@ -689,12 +688,12 @@ def getargs(co):
|
||||||
for i in range(nargs):
|
for i in range(nargs):
|
||||||
if args[i][:1] in ('', '.'):
|
if args[i][:1] in ('', '.'):
|
||||||
stack, remain, count = [], [], []
|
stack, remain, count = [], [], []
|
||||||
while step < len(code):
|
while step < len(co.co_code):
|
||||||
op = ord(code[step])
|
op = ord(co.co_code[step])
|
||||||
step = step + 1
|
step = step + 1
|
||||||
if op >= dis.HAVE_ARGUMENT:
|
if op >= dis.HAVE_ARGUMENT:
|
||||||
opname = dis.opname[op]
|
opname = dis.opname[op]
|
||||||
value = ord(code[step]) + ord(code[step+1])*256
|
value = ord(co.co_code[step]) + ord(co.co_code[step+1])*256
|
||||||
step = step + 2
|
step = step + 2
|
||||||
if opname in ('UNPACK_TUPLE', 'UNPACK_SEQUENCE'):
|
if opname in ('UNPACK_TUPLE', 'UNPACK_SEQUENCE'):
|
||||||
remain.append(value)
|
remain.append(value)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue