Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Include/internal/pycore_uop_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion Lib/test/test_list.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import sys
from test import list_tests
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
import pickle
import unittest

Expand Down Expand Up @@ -309,5 +312,20 @@ def test_tier2_invalidates_iterator(self):
a.append(4)
self.assertEqual(list(it), [])

@support.cpython_only
def test_no_memory(self):
# gh-118331: Make sure we don't crash if list allocation fails
import_module("_testcapi")
code = textwrap.dedent("""
import _testcapi, sys
# Prime the freelist
l = [None]
del l
_testcapi.set_nomemory(0)
l = [None]
""")
_, _, err = assert_python_failure("-c", code)
self.assertIn("MemoryError", err.decode("utf-8"))

if __name__ == "__main__":
unittest.main()
1 change: 1 addition & 0 deletions Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ list_dealloc(PyObject *self)
Py_XDECREF(op->ob_item[i]);
}
free_list_items(op->ob_item, false);
op->ob_item = NULL;
}
if (PyList_CheckExact(op)) {
_Py_FREELIST_FREE(lists, op, PyObject_GC_Del);
Expand Down
2 changes: 2 additions & 0 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Tools/cases_generator/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,6 @@ def has_error_without_pop(op: parser.CodeDef) -> bool:
"_PyGen_GetGeneratorFromFrame",
"_PyInterpreterState_GET",
"_PyList_AppendTakeRef",
"_PyList_FromStackRefStealOnSuccess",
"_PyList_ITEMS",
"_PyLong_CompactValue",
"_PyLong_DigitCount",
Expand Down
Loading