[Python-checkins] bpo-42979: _zoneinfo exec function checks for PyDateTime_IMPORT failure (GH-24333) (GH-24351)

vstinner webhook-mailer at python.org
Wed Jan 27 06:09:06 EST 2021


https://github.com/python/cpython/commit/895591c1f0bdec5ad357fe6a5fd0875990061357
commit: 895591c1f0bdec5ad357fe6a5fd0875990061357
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: vstinner <vstinner at python.org>
date: 2021-01-27T12:08:45+01:00
summary:

bpo-42979: _zoneinfo exec function checks for PyDateTime_IMPORT failure (GH-24333) (GH-24351)

Importing datetime can fail.
(cherry picked from commit eeb701adc0fc29ba803fddf133d917ff45639a00)

Co-authored-by: Hai Shi <shihai1992 at gmail.com>

Co-authored-by: Hai Shi <shihai1992 at gmail.com>

files:
M Modules/_zoneinfo.c

diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c
index 0913860a4d497..0a4b38a6dc5ad 100644
--- a/Modules/_zoneinfo.c
+++ b/Modules/_zoneinfo.c
@@ -2634,6 +2634,9 @@ static int
 zoneinfomodule_exec(PyObject *m)
 {
     PyDateTime_IMPORT;
+    if (PyDateTimeAPI == NULL) {
+        goto error;
+    }
     PyZoneInfo_ZoneInfoType.tp_base = PyDateTimeAPI->TZInfoType;
     if (PyType_Ready(&PyZoneInfo_ZoneInfoType) < 0) {
         goto error;



More information about the Python-checkins mailing list