[Python-checkins] bpo-43033: Fix the handling of PyObject_SetAttrString() in _zoneinfo.c (GH-24345) (GH-24349)

serhiy-storchaka webhook-mailer at python.org
Wed Jan 27 04:40:54 EST 2021


https://github.com/python/cpython/commit/cb77c5e1ddd9328e4706f8fdf893aa6bf697942c
commit: cb77c5e1ddd9328e4706f8fdf893aa6bf697942c
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: serhiy-storchaka <storchaka at gmail.com>
date: 2021-01-27T11:40:31+02:00
summary:

bpo-43033: Fix the handling of PyObject_SetAttrString() in _zoneinfo.c (GH-24345) (GH-24349)

(cherry picked from commit 5327f370344a627f1578d8183d197feb286371c6)

Co-authored-by: Zackery Spytz <zspytz at gmail.com>

files:
M Modules/_zoneinfo.c

diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c
index d87a20100a221..0913860a4d497 100644
--- a/Modules/_zoneinfo.c
+++ b/Modules/_zoneinfo.c
@@ -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;
 }



More information about the Python-checkins mailing list