mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
GH-97779: Ensure that *all* frame objects are backed by "complete" frames (GH-97845)
This commit is contained in:
parent
c3648f4e4a
commit
0ff8fd6583
5 changed files with 75 additions and 4 deletions
|
@ -132,6 +132,7 @@ import doctest
|
|||
import unittest
|
||||
import textwrap
|
||||
import weakref
|
||||
import dis
|
||||
|
||||
try:
|
||||
import ctypes
|
||||
|
@ -682,6 +683,38 @@ class CodeLocationTest(unittest.TestCase):
|
|||
self.check_lines(misshappen)
|
||||
self.check_lines(bug93662)
|
||||
|
||||
@cpython_only
|
||||
def test_code_new_empty(self):
|
||||
# If this test fails, it means that the construction of PyCode_NewEmpty
|
||||
# needs to be modified! Please update this test *and* PyCode_NewEmpty,
|
||||
# so that they both stay in sync.
|
||||
def f():
|
||||
pass
|
||||
PY_CODE_LOCATION_INFO_NO_COLUMNS = 13
|
||||
f.__code__ = f.__code__.replace(
|
||||
co_firstlineno=42,
|
||||
co_code=bytes(
|
||||
[
|
||||
dis.opmap["RESUME"], 0,
|
||||
dis.opmap["LOAD_ASSERTION_ERROR"], 0,
|
||||
dis.opmap["RAISE_VARARGS"], 1,
|
||||
]
|
||||
),
|
||||
co_linetable=bytes(
|
||||
[
|
||||
(1 << 7)
|
||||
| (PY_CODE_LOCATION_INFO_NO_COLUMNS << 3)
|
||||
| (3 - 1),
|
||||
0,
|
||||
]
|
||||
),
|
||||
)
|
||||
self.assertRaises(AssertionError, f)
|
||||
self.assertEqual(
|
||||
list(f.__code__.co_positions()),
|
||||
3 * [(42, 42, None, None)],
|
||||
)
|
||||
|
||||
|
||||
if check_impl_detail(cpython=True) and ctypes is not None:
|
||||
py = ctypes.pythonapi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue