Skip to content

Commit 7e9154b

Browse files
committed
Don't parse tzinfo in C implementation when invalid iso midnight
1 parent c4ae31b commit 7e9154b

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
@@ -4629,13 +4629,6 @@ time_fromisoformat(PyObject *cls, PyObject *tstr) {
46294629
goto invalid_string_error;
46304630
}
46314631

4632-
PyObject *tzinfo = tzinfo_from_isoformat_results(rv, tzoffset,
4633-
tzimicrosecond);
4634-
4635-
if (tzinfo == NULL) {
4636-
return NULL;
4637-
}
4638-
46394632
if (hour == 24) {
46404633
if (minute == 0 && second == 0 && microsecond == 0) {
46414634
hour = 0;
@@ -4644,6 +4637,13 @@ time_fromisoformat(PyObject *cls, PyObject *tstr) {
46444637
}
46454638
}
46464639

4640+
PyObject *tzinfo = tzinfo_from_isoformat_results(rv, tzoffset,
4641+
tzimicrosecond);
4642+
4643+
if (tzinfo == NULL) {
4644+
return NULL;
4645+
}
4646+
46474647
PyObject *t;
46484648
if ( (PyTypeObject *)cls == &PyDateTime_TimeType ) {
46494649
t = new_time(hour, minute, second, microsecond, tzinfo, 0);

0 commit comments

Comments
 (0)