[New-bugs-announce] [issue26448] dis.findlabels ignores EXTENDED_ARG
Eric Fahlgren
report at bugs.python.org
Fri Feb 26 22:54:10 EST 2016
New submission from Eric Fahlgren:
When trying out dis.dis on some synthetically long functions, I noted that spurious branch targets were being generated in the output. First one is at address 8:
157 0 LOAD_CONST 1 (1)
3 DUP_TOP
4 STORE_FAST 0 (z)
7 DUP_TOP
>> 8 STORE_FAST 1 (a)
11 DUP_TOP
I dug into findlabels and notices that it pays no attention to EXTENDED_ARG. The fix is pretty simple, basically copy pasta from dis._get_instructions_bytes, at line 369, in the 3.5.1 release code add all the "extended_arg" bits:
extended_arg = 0
while i < n:
op = code[i]
i = i+1
if op >= HAVE_ARGUMENT:
arg = code[i] + code[i+1]*256 + extended_arg
extended_arg = 0
i = i+2
if op == EXTENDED_ARG:
extended_arg = arg*65536
label = -1
----------
components: Library (Lib)
messages: 260913
nosy: eric.fahlgren
priority: normal
severity: normal
status: open
title: dis.findlabels ignores EXTENDED_ARG
type: behavior
versions: Python 3.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26448>
_______________________________________
More information about the New-bugs-announce
mailing list