Skip to content

fix(parsing): accept subsecond fractions longer than nine digits - #999

Open
abhijeet117 wants to merge 1 commit into
python-pendulum:masterfrom
abhijeet117:fix/parse-long-subsecond
Open

fix(parsing): accept subsecond fractions longer than nine digits#999
abhijeet117 wants to merge 1 commit into
python-pendulum:masterfrom
abhijeet117:fix/parse-long-subsecond

Conversation

@abhijeet117

Copy link
Copy Markdown

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

  • Added tests for changed code
  • Bug reproduced before the fix
  • Root cause identified
  • Tests passed

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant