fix(parsing): accept subsecond fractions longer than nine digits - #999
Open
abhijeet117 wants to merge 1 commit into
Open
fix(parsing): accept subsecond fractions longer than nine digits#999abhijeet117 wants to merge 1 commit into
abhijeet117 wants to merge 1 commit into
Conversation
The pure-Python ISO 8601 and common parsers capped the subsecond capture at nine digits, so strings like "2001-01-01T12:34:56.1234567890" raised ParserError while the compiled parser truncates them to microseconds. Capture any number of digits; the existing [:6] slice plus zero-padding already reduces them to microsecond resolution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The pure-Python parsers capped the subsecond capture at nine digits, so ISO 8601 strings with longer fractional parts raised ParserError while the compiled Rust parser truncates them to microsecond resolution. pendulum.parse therefore behaved differently depending on whether the compiled extension was available. Both the ISO 8601 and common regexes now accept any number of digits; the existing truncation to microseconds applies.
Testing
Reproduced on master with PENDULUM_EXTENSIONS=0: "2001-01-01T12:34:56.1234567890Z" raised ParserError. Added parametrized cases for twelve-digit fractions in datetime, time, comma separator and common formats. New tests fail before the fix and pass after; full test suite passes in pure-Python mode (1842 passed).
Checklist