]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43033: Fix the handling of PyObject_SetAttrString() in _zoneinfo.c (GH-24345...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 27 Jan 2021 09:40:31 +0000 (01:40 -0800)
committerGitHub <noreply@github.com>
Wed, 27 Jan 2021 09:40:31 +0000 (11:40 +0200)
(cherry picked from commit 5327f370344a627f1578d8183d197feb286371c6)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Modules/_zoneinfo.c

index d87a20100a22189306769bcb48fc15602aa0aaac..0913860a4d49704376e54e172f988fd3d18816b5 100644 (file)
@@ -2530,7 +2530,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;
 }