diff options
author | serge-sans-paille <serge.guelton@telecom-bretagne.eu> | 2022-09-20 10:00:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-20 10:00:34 (GMT) |
commit | fc05107af9f20b9d926dedc5bf12d75b0eaa45a3 (patch) | |
tree | fe4f97cfa2b2b885cd798101085586ce92b20564 /Lib | |
parent | 6ad47b41a650a13b4a9214309c10239726331eb8 (diff) | |
download | cpython-fc05107af9f20b9d926dedc5bf12d75b0eaa45a3.zip cpython-fc05107af9f20b9d926dedc5bf12d75b0eaa45a3.tar.gz cpython-fc05107af9f20b9d926dedc5bf12d75b0eaa45a3.tar.bz2 |
gh-96711: Enhance SystemError message upon Invalid opcode (#96712)
Raise verbose SystemError instead of printing debug information
upon Invalid opcode.
Fix #96711
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_code.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py index 2386cf6..2fdfdd0 100644 --- a/Lib/test/test_code.py +++ b/Lib/test/test_code.py @@ -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 |