bpo-46724: Fix dis support for overflow args (GH-31285)

This commit is contained in:
Saul Shanabrook 2022-02-18 04:56:23 -05:00 committed by GitHub
parent 2923d87ca2
commit c3ce7781e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 5 deletions

View file

@ -1,14 +1,17 @@
# Minimal tests for dis module
from test.support import captured_stdout, requires_debug_ranges
from test.support.bytecode_helper import BytecodeTestCase
import unittest
import sys
import contextlib
import dis
import io
import re
import sys
import types
import contextlib
import unittest
from test.support import captured_stdout, requires_debug_ranges
from test.support.bytecode_helper import BytecodeTestCase
import opcode
def get_tb():
def _error():
@ -219,6 +222,22 @@ dis_bug_45757 = """\
RETURN_VALUE
"""
# [255, 255, 255, 252] is -4 in a 4 byte signed integer
bug46724 = bytes([
opcode.EXTENDED_ARG, 255,
opcode.EXTENDED_ARG, 255,
opcode.EXTENDED_ARG, 255,
opcode.opmap['JUMP_FORWARD'], 252,
])
dis_bug46724 = """\
>> EXTENDED_ARG 255
EXTENDED_ARG 65535
EXTENDED_ARG 16777215
JUMP_FORWARD -4 (to 0)
"""
_BIG_LINENO_FORMAT = """\
1 RESUME 0
@ -688,6 +707,10 @@ class DisTests(DisTestBase):
# Extended arg followed by NOP
self.do_disassembly_test(code_bug_45757, dis_bug_45757)
def test_bug_46724(self):
# Test that negative operargs are handled properly
self.do_disassembly_test(bug46724, dis_bug46724)
def test_big_linenos(self):
def func(count):
namespace = {}