]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-42979: _zoneinfo exec function checks for PyDateTime_IMPORT failure (GH-24333...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 27 Jan 2021 11:08:45 +0000 (03:08 -0800)
committerGitHub <noreply@github.com>
Wed, 27 Jan 2021 11:08:45 +0000 (12:08 +0100)
Importing datetime can fail.
(cherry picked from commit eeb701adc0fc29ba803fddf133d917ff45639a00)

Co-authored-by: Hai Shi <shihai1992@gmail.com>
Co-authored-by: Hai Shi <shihai1992@gmail.com>
Modules/_zoneinfo.c

index 0913860a4d49704376e54e172f988fd3d18816b5..0a4b38a6dc5ad7e72e8d4d85e15897533ffaf93c 100644 (file)
@@ -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;