8000 Raise error on unsupported ISO 8601 time strings · python/cpython@3bdb081 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 3bdb081

Browse files
committed
Raise error on unsupported ISO 8601 time strings
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.
1 parent b7f45a9 commit 3bdb081

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Modules/_datetimemodule.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,9 @@ parse_hh_mm_ss_ff(const char *tstr, const char *tstr_end, int *hour,
859859
continue;
860860
}
861861
else if (c == '.' || c == ',') {
862+
if (i < 2) {
863+
return -3; // Decimal mark on hour or minute
864+
}
862865
break;
863866
} else if (!has_separator) {
864867
--p;

0 commit comments

Comments
 (0)
0