Repository navigation
parser: accept a 9-digit HHMMSSmmm time token (#1442) - #1603
DawnofGenX wants to merge 2 commits into
Conversation
`parser.parse("20010203 040506789")` raised `ParserError` because a
9-digit numeric token matched no branch in `_parse_numeric_token` and fell
through to the year path. Treat it as `HHMMSSmmm` when a date has already
been seen and the hour is still unset.
5a529a6 to
6cce9be
Compare
Wkhanex
left a comment
There was a problem hiding this comment.
Nine-digit time tokens agree with direct datetime construction at midnight, ordinary times and 23:59:59, with millisecond values 000, 001, 009, 100 and 999. Invalid hour/minute/second fields still raise ParserError.
Checked 6cce9be50917 with standalone Python 3.12.14 checks (18 passing assertions). I haven't run the full upstream suite.
…econds-1442 # Conflicts: # tests/test_internals.py
|
Merged current Re-verified on the merged tree: |
Problem
parser.parse()rejects a bare 9-digit time token (hour-minute-second plusmilliseconds, no decimal point):
strptimehandles the same string with%Y%m%d %H%M%S%f. A 9-digit tokenmatches no branch in
_parse_numeric_token, so it falls through to the yearpath and fails.
Changes
Add an
HHMMSSmmmbranch for a 9-digit token when a date has already been seenand the hour is not yet set.
Verification
ParserTest::testHHMMSSMillisecondsfails onmain(ParserError)and passes with the fix, for both
"20010203 040506789"and"20010203T040506789".tests/test_parser.py: 232 passed, 14 xfailed.tests/property, which needs a data file absent here):only pre-existing
tests/test_tz.pyfailures remain, which reproduceidentically on
main.