aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Modules/_zoneinfo.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c
index d1e09340d1d..4a4cbdbee38 100644
--- a/Modules/_zoneinfo.c
+++ b/Modules/_zoneinfo.c
@@ -2525,7 +2525,11 @@ zoneinfo_init_subclass(PyTypeObject *cls, PyObject *args, PyObject **kwargs)
return NULL;
}
- PyObject_SetAttrString((PyObject *)cls, "_weak_cache", weak_cache);
+ if (PyObject_SetAttrString((PyObject *)cls, "_weak_cache",
+ weak_cache) < 0) {
+ Py_DECREF(weak_cache);
+ return NULL;
+ }
Py_DECREF(weak_cache);
Py_RETURN_NONE;
}