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

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

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

Co-authored-by: Hai Shi <shihai1992@gmail.com>
This commit is contained in:
Miss Islington (bot) 2021-01-27 03:08:45 -08:00 committed by GitHub
parent cb77c5e1dd
commit 895591c1f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View 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;