8000 [3.12] Fix undefined behaviour in datetime.time.fromisoformat() (GH-1… · python/cpython@1afc4dc · GitHub
[go: up one dir, main page]

Skip to content

Commit 1afc4dc

Browse files
[3.12] Fix undefined behaviour in datetime.time.fromisoformat() (GH-111982) (#111992)
Fix undefined behaviour in datetime.time.fromisoformat() (GH-111982) Fix undefined behaviour in datetime.time.fromisoformat() when parsing a string without a timezone. 'tzoffset' is not assigned to by parse_isoformat_time if it returns 0, but time_fromisoformat then passes tzoffset to another function, which is undefined behaviour (even if the function in question does not use the value). (cherry picked from commit 21615f7) Co-authored-by: T. Wouters <thomas@python.org>
1 parent 0f7671c commit 1afc4dc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Modules/_datetimemodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4620,7 +4620,7 @@ time_fromisoformat(PyObject *cls, PyObject *tstr) {
46204620
}
46214621

46224622
int hour = 0, minute = 0, second = 0, microsecond = 0;
4623-
int tzoffset, tzimicrosecond = 0;
4623+
int tzoffset = 0, tzimicrosecond = 0;
46244624
int rv = parse_isoformat_time(p, len,
46254625
&hour, &minute, &second, &microsecond,
46264626
&tzoffset, &tzimicrosecond);

0 commit comments

Comments
 (0)
0