Skip to content

fix(parsing): allow more than 9 subsecond digits in ISO 8601 - #1055

Open
christiandovison6-droid wants to merge 2 commits into
python-pendulum:masterfrom
christiandovison6-droid:fix-iso8601-subsecond-digits
Open

christiandovison6-droid wants to merge 2 commits into
python-pendulum:masterfrom
christiandovison6-droid:fix-iso8601-subsecond-digits

Conversation

@christiandovison6-droid

Copy link
Copy Markdown

Problem

pendulum.parse() raises ParserError on ISO 8601 strings with more
than 9 fractional-second digits, e.g.:

pendulum.parse("2001-01-01T12:34:56.1234567890Z")

The pure-Python parser bounded the subsecond capture group to \d{1,9}.
The Rust extension and datetime.datetime.fromisoformat() both accept
longer fractions and truncate to microsecond precision.

Fix

Widen the subsecond capture group in src/pendulum/parsing/iso8601.py
from \d{1,9} to \d+. The existing [:6] truncation already handles
arbitrary-length fractions.

Tests

Added test_parse_iso8601_subsecond_more_than_nine_digits in
tests/parsing/test_parse_iso8601.py. It fails before the change and
passes after. Full tests/parsing/ suite passes.

Closes #935

This branch has not been deployed

No deployments
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.

parse fails with subsecond decimals with more than 9 digits

1 participant