Some time strings that contain fractional hours or minutes are permitted
by ISO 8601, but such strings are very unlikely to be intentional. The
current parser does not parse such strings correctly or raise an error.
This change raises a ValueError when hours or minutes contain a decimal mark.
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
'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:
Mitch Chapman
Matt Chaput
William Chargin
+Ben Chatterton
Yogesh Chaudhari
Gautam Chaudhuri
David Chaum
--- /dev/null
+Raise error on certain technically valid but pathological ISO 8601 strings passed to :meth:`datetime.time.fromisoformat` that were previously parsed incorrectly.
continue;
}
else if (c == '.' || c == ',') {
+ if (i < 2) {
+ return -3; // Decimal mark on hour or minute
+ }
break;
} else if (!has_separator) {
--p;