Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions Lib/test/datetimetester.py
Original file line number Diff line number Diff line change
Expand Up @@ -4412,6 +4412,8 @@ def test_fromisoformat_fails(self):
'12:30:45.123456-', # Extra at end of microsecond time
'12:30:45.123456+', # Extra at end of microsecond time
'12:30:45.123456+12:00:30a', # Extra at end of full time
'12.5', # Decimal mark at end of hour
'12:30,5', # Decimal mark at end of minute
]

for bad_str in bad_strs:
Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ Greg Chapman
Mitch Chapman
Matt Chaput
William Chargin
Ben Chatterton
Yogesh Chaudhari
Gautam Chaudhuri
David Chaum
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Raise error on certain technically valid but pathological ISO 8601 strings passed to :meth:`datetime.time.fromisoformat` that were previously parsed incorrectly.
Comment thread
benchatt marked this conversation as resolved.
3 changes: 3 additions & 0 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,9 @@ parse_hh_mm_ss_ff(const char *tstr, const char *tstr_end, int *hour,
continue;
}
else if (c == '.' || c == ',') {
if (i < 2) {
return -3; // Decimal mark on hour or minute
}
break;
} else if (!has_separator) {
--p;
Expand Down