]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-35373: Fix PyInit_timezone() if HAVE_DECL_TZNAME is defined (GH-10861)
authorVictor Stinner <vstinner@redhat.com>
Mon, 3 Dec 2018 11:02:43 +0000 (12:02 +0100)
committerGitHub <noreply@github.com>
Mon, 3 Dec 2018 11:02:43 +0000 (12:02 +0100)
If HAVE_DECL_TZNAME, PyInit_timezone() now returns -1 on error.

Modules/timemodule.c

index 188f1e6ef57118d0ff14eef6a948257ef90ec468..61041c90b87ed38cb2051a6e7f94d7a0c16e538b 100644 (file)
@@ -1581,16 +1581,17 @@ PyInit_timezone(PyObject *m)
     PyModule_AddIntConstant(m, "daylight", daylight);
     otz0 = PyUnicode_DecodeLocale(tzname[0], "surrogateescape");
     if (otz0 == NULL) {
-        return;
+        return -1;
     }
     otz1 = PyUnicode_DecodeLocale(tzname[1], "surrogateescape");
     if (otz1 == NULL) {
         Py_DECREF(otz0);
-        return;
+        return -1;
     }
     PyObject *tzname_obj = Py_BuildValue("(NN)", otz0, otz1);
-    if (tzname_obj == NULL)
-        return;
+    if (tzname_obj == NULL) {
+        return -1;
+    }
     PyModule_AddObject(m, "tzname", tzname_obj);
 #else // !HAVE_DECL_TZNAME
     static const time_t YEAR = (365 * 24 + 6) * 3600;