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 3f699a50d7a42b..4918d6f7e348de 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 eaffd020ed97c0..777b93fdf5460e 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; }