gh-132011: Fix crash on invalid CALL_LIST_APPEND deoptimization (#132018)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
This commit is contained in:
sobolevn 2025-04-06 19:10:39 +03:00 committed by GitHub
parent 42e3a8410b
commit c0661df42a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 32 additions and 4 deletions

View file

@ -4,7 +4,7 @@ import textwrap
from test import list_tests, support
from test.support import cpython_only
from test.support.import_helper import import_module
from test.support.script_helper import assert_python_failure
from test.support.script_helper import assert_python_failure, assert_python_ok
import pickle
import unittest
@ -332,5 +332,25 @@ class ListTest(list_tests.CommonTest):
else:
self.assertNotEqual(rc, -int(signal.SIGSEGV))
def test_deopt_from_append_list(self):
# gh-132011: it used to crash, because
# of `CALL_LIST_APPEND` specialization failure.
code = textwrap.dedent("""
l = []
def lappend(l, x, y):
l.append((x, y))
for x in range(3):
lappend(l, None, None)
try:
lappend(list, None, None)
except TypeError:
pass
else:
raise AssertionError
""")
rc, _, _ = assert_python_ok("-c", code)
self.assertEqual(rc, 0)
if __name__ == "__main__":
unittest.main()