Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix error handling in the :mod:`zoneinfo` accelerator module when a
transition index is ``-1`` or a TZ string's ``__bool__`` raises.
9 changes: 7 additions & 2 deletions Modules/_zoneinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ load_data(zoneinfo_state *state, PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
}

Py_ssize_t cur_trans_idx = PyLong_AsSsize_t(num);
if (cur_trans_idx == -1) {
if (cur_trans_idx == -1 && PyErr_Occurred()) {
goto error;
}

Expand Down Expand Up @@ -1178,7 +1178,12 @@ load_data(zoneinfo_state *state, PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
self->ttinfo_before = &(self->_ttinfos[0]);
}

if (tz_str != Py_None && PyObject_IsTrue(tz_str)) {
int has_tz_str = PyObject_IsTrue(tz_str);
if (has_tz_str < 0) {
goto error;
}

if (has_tz_str) {
if (parse_tz_str(state, tz_str, &(self->tzrule_after))) {
goto error;
}
Expand Down
Loading