import sys
+import textwrap
from test import list_tests
from test.support import cpython_only
+from test.support.script_helper import assert_python_ok
import pickle
import unittest
a.append(4)
self.assertEqual(list(it), [])
+ 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()
assert(oparg == 1);
PyInterpreterState *interp = tstate->interp;
DEOPT_IF(callable != interp->callable_cache.list_append);
- assert(self != NULL);
+ DEOPT_IF(self == NULL);
DEOPT_IF(!PyList_Check(self));
STAT_INC(CALL, hit);
if (_PyList_AppendTakeRef((PyListObject *)self, arg) < 0) {
assert(oparg == 1);
PyInterpreterState *interp = tstate->interp;
DEOPT_IF(callable != interp->callable_cache.list_append, CALL);
- assert(self != NULL);
+ DEOPT_IF(self == NULL, CALL);
DEOPT_IF(!PyList_Check(self), CALL);
STAT_INC(CALL, hit);
if (_PyList_AppendTakeRef((PyListObject *)self, arg) < 0) {