Skip to content

Commit e24c59c

Browse files
committed
Raise also MemoryError in parse_transition_rule()
1 parent 457b99f commit e24c59c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Modules/_zoneinfo.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,9 +1677,11 @@ parse_tz_str(zoneinfo_state *state, PyObject *tz_str_obj, _tzrule *out)
16771677
p++;
16781678

16791679
if (parse_transition_rule(&p, transitions[i])) {
1680-
PyErr_Format(PyExc_ValueError,
1681-
"Malformed transition rule in TZ string: %R",
1682-
tz_str_obj);
1680+
if (!PyErr_ExceptionMatches(PyExc_MemoryError)) {
1681+
PyErr_Format(PyExc_ValueError,
1682+
"Malformed transition rule in TZ string: %R",
1683+
tz_str_obj);
1684+
}
16831685
goto error;
16841686
}
16851687
}
@@ -1879,6 +1881,7 @@ parse_transition_rule(const char **p, TransitionRuleType **out)
18791881

18801882
CalendarRule *rv = PyMem_Calloc(1, sizeof(CalendarRule));
18811883
if (rv == NULL) {
1884+
PyErr_NoMemory();
18821885
return -1;
18831886
}
18841887

@@ -1910,6 +1913,7 @@ parse_transition_rule(const char **p, TransitionRuleType **out)
19101913

19111914
DayRule *rv = PyMem_Calloc(1, sizeof(DayRule));
19121915
if (rv == NULL) {
1916+
PyErr_NoMemory();
19131917
return -1;
19141918
}
19151919

0 commit comments

Comments
 (0)