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 @@ -523,6 +523,7 @@ def _unpack_opargs(code):
523
523
extended_arg = (arg << 8 ) if op == EXTENDED_ARG else 0
524
524
else :
525
525
arg = None
526
+ extended_arg = 0
526
527
yield (i , op , arg )
527
528
528
529
def findlabels (code ):
Original file line number Diff line number Diff line change @@ -179,6 +179,23 @@ def bug42562():
179
179
2 RETURN_VALUE
180
180
"""
181
181
182
+ # Extended arg followed by NOP
183
+ code_bug_45757 = bytes ([
184
+ 0x90 , 0x01 , # EXTENDED_ARG 0x01
185
+ 0x09 , 0xFF , # NOP 0xFF
186
+ 0x90 , 0x01 , # EXTENDED_ARG 0x01
187
+ 0x64 , 0x29 , # LOAD_CONST 0x29
188
+ 0x53 , 0x00 , # RETURN_VALUE 0x00
189
+ ])
190
+
191
+ dis_bug_45757 = """\
192
+ 0 EXTENDED_ARG 1
193
+ 2 NOP
194
+ 4 EXTENDED_ARG 1
195
+ 6 LOAD_CONST 297
196
+ 8 RETURN_VALUE
197
+ """
198
+
182
199
_BIG_LINENO_FORMAT = """\
183
200
%3d 0 LOAD_GLOBAL 0 (spam)
184
201
2 POP_TOP
@@ -547,6 +564,10 @@ def test_bug_1333982(self):
547
564
def test_bug_42562 (self ):
548
565
self .do_disassembly_test (bug42562 , dis_bug42562 )
549
566
567
+ def test_bug_45757 (self ):
568
+ # Extended arg followed by NOP
569
+ self .do_disassembly_test (code_bug_45757 , dis_bug_45757 )
570
+
550
571
def test_big_linenos (self ):
551
572
def func (count ):
552
573
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