From 65eebcf6906fe1e716f514cc34fe44e1435e669c Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 9 Jun 2026 13:11:03 +0300 Subject: [PATCH] gh-151126: Add `PyErr_NoMemory()` in `strong_cache_node_new` --- .../2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst | 7 +++++-- Modules/_zoneinfo.c | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) 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 index 3f699a50d7a42bb..4918d6f7e348ded 100644 --- 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 @@ -1,3 +1,6 @@ Fix a crash, when there's no memory left on a device, -which happened in code compilation. -Now it raises a proper :exc:`MemoryError`. +which happened in: +- Code compilation +- :mod:`zoneinfo` caching + +Now these places raise a proper :exc:`MemoryError`. diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c index eaffd020ed97c09..777b93fdf5460e8 100644 --- a/Modules/_zoneinfo.c +++ b/Modules/_zoneinfo.c @@ -2353,6 +2353,7 @@ strong_cache_node_new(PyObject *key, PyObject *zone) { StrongCacheNode *node = PyMem_Malloc(sizeof(StrongCacheNode)); if (node == NULL) { + PyErr_NoMemory(); return NULL; }