mirror of
https://github.com/python/cpython.git
synced 2025-10-08 16:11:51 +00:00
gh-96711: Enhance SystemError message upon Invalid opcode (#96712)
Raise verbose SystemError instead of printing debug information upon Invalid opcode. Fix #96711
This commit is contained in:
parent
6ad47b41a6
commit
fc05107af9
2 changed files with 16 additions and 3 deletions
|
@ -337,6 +337,17 @@ class CodeTest(unittest.TestCase):
|
|||
new_code = code = func.__code__.replace(co_linetable=b'')
|
||||
self.assertEqual(list(new_code.co_lines()), [])
|
||||
|
||||
def test_invalid_bytecode(self):
|
||||
def foo(): pass
|
||||
foo.__code__ = co = foo.__code__.replace(co_code=b'\xee\x00d\x00S\x00')
|
||||
|
||||
with self.assertRaises(SystemError) as se:
|
||||
foo()
|
||||
self.assertEqual(
|
||||
f"{co.co_filename}:{co.co_firstlineno}: unknown opcode 238",
|
||||
str(se.exception))
|
||||
|
||||
|
||||
@requires_debug_ranges()
|
||||
def test_co_positions_artificial_instructions(self):
|
||||
import dis
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue