Skip to content

Commit 004a5ff

Browse files
committed
Don't parse tzinfo in C implementation when invalid iso midnight
1 parent c9db98b commit 004a5ff

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Modules/_datetimemodule.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4997,13 +4997,6 @@ time_fromisoformat(PyObject *cls, PyObject *tstr) {
49974997
goto invalid_string_error;
49984998
}
49994999

5000-
PyObject *tzinfo = tzinfo_from_isoformat_results(rv, tzoffset,
5001-
tzimicrosecond);
5002-
5003-
if (tzinfo == NULL) {
5004-
return NULL;
5005-
}
5006-
50075000
if (hour == 24) {
50085001
if (minute == 0 && second == 0 && microsecond == 0) {
50095002
hour = 0;
@@ -5012,6 +5005,13 @@ time_fromisoformat(PyObject *cls, PyObject *tstr) {
50125005
}
50135006
}
50145007

5008+
PyObject *tzinfo = tzinfo_from_isoformat_results(rv, tzoffset,
5009+
tzimicrosecond);
5010+
5011+
if (tzinfo == NULL) {
5012+
return NULL;
5013+
}
5014+
50155015
PyObject *t;
50165016
if ( (PyTypeObject *)cls == TIME_TYPE(NO_STATE)) {
50175017
t = new_time(hour, minute, second, microsecond, tzinfo, 0);

0 commit comments

Comments
 (0)