raise ValueError("Invalid microsecond separator")
else:
pos += 1
+ if not all(map(_is_ascii_digit, tstr[pos:])):
+ raise ValueError("Non-digit values in fraction")
len_remainder = len_str - pos
time_comps[3] = int(tstr[pos:(pos+to_parse)])
if to_parse < 6:
time_comps[3] *= _FRACTION_CORRECTION[to_parse-1]
- if (len_remainder > to_parse
- and not all(map(_is_ascii_digit, tstr[(pos+to_parse):]))):
- raise ValueError("Non-digit values in unparsed fraction")
return time_comps
'9999-12-31T24:00:00.000000', # Year is invalid after wrapping due to 24:00
'2009-04-19T12:30Z12:00', # Extra time zone info after Z
'2009-04-19T12:30:45:334034', # Invalid microsecond separator
+ '2009-04-19T12:30:45.400 +02:30', # Space between ms and timezone (gh-130959)
+ '2009-04-19T12:30:45.400 ', # Trailing space (gh-130959)
+ '2009-04-19T12:30:45. 400', # Space before fraction (gh-130959)
]
for bad_str in bad_strs:
'12:30,5', # Decimal mark at end of minute
'12:30:45.123456Z12:00', # Extra time zone info after Z
'12:30:45:334034', # Invalid microsecond separator
+ '12:30:45.400 +02:30', # Space between ms and timezone (gh-130959)
+ '12:30:45.400 ', # Trailing space (gh-130959)
+ '12:30:45. 400', # Space before fraction (gh-130959)
]
for bad_str in bad_strs:
--- /dev/null
+Fix pure-Python implementation of :func:`datetime.time.fromisoformat` to reject
+times with spaces in fractional part (for example, ``12:34:56.400 +02:00``),
+matching the C implementation. Patch by Michał Gorny.