8000 [3.12] Fix undefined behaviour in datetime.time.fromisoformat() (GH-111982) by miss-islington · Pull Request #111992 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.12] Fix undefined behaviour in datetime.time.fromisoformat() (GH-111982) #111992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 12, 2023
Merged
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
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>
  • Loading branch information
Yhg1s authored and miss-islington committed Nov 12, 2023
commit 0be1f1b24c960fda99ff1683c43c97ee26d735dd
2 changes: 1 addition & 1 deletion Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4620,7 +4620,7 @@ time_fromisoformat(PyObject *cls, PyObject *tstr) {
}

int hour = 0, minute = 0, second = 0, microsecond = 0;
int tzoffset, tzimicrosecond = 0;
int tzoffset = 0, tzimicrosecond = 0;
int rv = parse_isoformat_time(p, len,
&hour, &minute, &second, &microsecond,
&tzoffset, &tzimicrosecond);
Expand Down
0