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

Importing datetime can fail.
This commit is contained in:
Hai Shi 2021-01-27 18:23:33 +08:00 committed by GitHub
parent 6790005a9a
commit eeb701adc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

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