summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2021-01-27 10:23:33 (GMT)
committerGitHub <noreply@github.com>2021-01-27 10:23:33 (GMT)
commiteeb701adc0fc29ba803fddf133d917ff45639a00 (patch)
tree08e5837b88ea38c1cec672ca79082d3f4ab46bfb
parent6790005a9a30ae3eca69d1957fb072171643a366 (diff)
downloadcpython-eeb701adc0fc29ba803fddf133d917ff45639a00.zip
cpython-eeb701adc0fc29ba803fddf133d917ff45639a00.tar.gz
cpython-eeb701adc0fc29ba803fddf133d917ff45639a00.tar.bz2
bpo-42979: _zoneinfo exec function checks for PyDateTime_IMPORT failure (GH-24333)
Importing datetime can fail.
-rw-r--r--Modules/_zoneinfo.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c
index 4a4cbdb..d0c462f 100644
--- a/Modules/_zoneinfo.c
+++ b/Modules/_zoneinfo.c
@@ -2629,6 +2629,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;