https://github.com/python/cpython/commit/5c6402e6a509b248acf273d613590ce699647a89 commit: 5c6402e6a509b248acf273d613590ce699647a89 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: sobolevn <[email protected]> date: 2026-06-09T10:33:08Z summary:
[3.14] gh-151126: Fix missing `PyErr_NoMemory()` in `remove_unused_consts` (GH-151127) (#151135) gh-151126: Fix missing `PyErr_NoMemory()` in `remove_unused_consts` (GH-151127) (cherry picked from commit 3186547c1ec76e1afab82ec32271ec5b9467fdeb) Co-authored-by: sobolevn <[email protected]> files: A Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst M Python/flowgraph.c diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst new file mode 100644 index 00000000000000..3f699a50d7a42b --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst @@ -0,0 +1,3 @@ +Fix a crash, when there's no memory left on a device, +which happened in code compilation. +Now it raises a proper :exc:`MemoryError`. diff --git a/Python/flowgraph.c b/Python/flowgraph.c index eff2fc90d3c02d..2d710898913bfa 100644 --- a/Python/flowgraph.c +++ b/Python/flowgraph.c @@ -3185,6 +3185,7 @@ remove_unused_consts(basicblock *entryblock, PyObject *consts) index_map = PyMem_Malloc(nconsts * sizeof(Py_ssize_t)); if (index_map == NULL) { + PyErr_NoMemory(); goto end; } for (Py_ssize_t i = 1; i < nconsts; i++) { @@ -3237,6 +3238,7 @@ remove_unused_consts(basicblock *entryblock, PyObject *consts) /* adjust const indices in the bytecode */ reverse_index_map = PyMem_Malloc(nconsts * sizeof(Py_ssize_t)); if (reverse_index_map == NULL) { + PyErr_NoMemory(); goto end; } for (Py_ssize_t i = 0; i < nconsts; i++) { _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
