File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -428,6 +428,7 @@ def _unpack_opargs(code):
428
428
extended_arg = (arg << 8 ) if op == EXTENDED_ARG else 0
429
429
else :
430
430
arg = None
431
+ extended_arg = 0
431
432
yield (i , op , arg )
432
433
433
434
def findlabels (code ):
Original file line number Diff line number Diff line change @@ -180,6 +180,23 @@ def bug42562():
180
180
2 RETURN_VALUE
181
181
"""
182
182
183
+ # Extended arg followed by NOP
184
+ code_bug_45757 = bytes ([
185
+ 0x90 , 0x01 , # EXTENDED_ARG 0x01
186
+ 0x09 , 0xFF , # NOP 0xFF
187
+ 0x90 , 0x01 , # EXTENDED_ARG 0x01
188
+ 0x64 , 0x29 , # LOAD_CONST 0x29
189
+ 0x53 , 0x00 , # RETURN_VALUE 0x00
190
+ ])
191
+
192
+ dis_bug_45757 = """\
193
+ 0 EXTENDED_ARG 1
194
+ 2 NOP
195
+ 4 EXTENDED_ARG 1
196
+ 6 LOAD_CONST 297 (297)
197
+ 8 RETURN_VALUE
198
+ """
199
+
183
200
_BIG_LINENO_FORMAT = """\
184
201
%3d 0 LOAD_GLOBAL 0 (spam)
185
202
2 POP_TOP
@@ -534,6 +551,10 @@ def test_bug_1333982(self):
534
551
def test_bug_42562 (self ):
535
552
self .do_disassembly_test (bug42562 , dis_bug42562 )
536
553
554
+ def test_bug_45757 (self ):
555
+ # Extended arg followed by NOP
556
+ self .do_disassembly_test (code_bug_45757 , dis_bug_45757 )
557
+
537
558
def test_big_linenos (self ):
538
559
def func (count ):
539
560
namespace = {}
Original file line number Diff line number Diff line change
1
+ Fix bug where :mod: `dis ` produced an incorrect oparg when :opcode: `EXTENDED_ARG ` is followed by an opcode that does not use its argument.
You can’t perform that action at this time.
0 commit comments