Skip to content

Parse a year-only ISO 8601 date in the Rust parser - #1106

Open
dylanpulver wants to merge 1 commit into
python-pendulum:masterfrom
dylanpulver:parse-iso8601-year-only
Open

dylanpulver wants to merge 1 commit into
python-pendulum:masterfrom
dylanpulver:parse-iso8601-year-only

Conversation

@dylanpulver

Copy link
Copy Markdown
Contributor

With the Rust extension (the default), parse_iso8601("2016") raises "Unexpected end of string while parsing month", while the pure-Python parser returns date(2016, 1, 1); its regex already treats the month as optional. The visible symptom is pendulum.parse("2016/2017"), which raises ValueError: month must be in 1..12, not 20 with the extension and returns Interval[2016-01-01 -> 2017-01-01] with PENDULUM_EXTENSIONS=0.

I first also accepted a / after the year, but Python splits intervals before Rust sees the string, so that arm was dead and I dropped it.

pytest tests gives 1871 passed with both PENDULUM_EXTENSIONS=1 and 0. Reverting parsing.rs fails both new tests with the extension. test_instance_with_aware_datetime_any_tzinfo fails on unmodified master too.

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codspeed

codspeed Bot commented Dec 4, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

1 note

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: the symbols of the profiling trace could not be resolved, because no information about the language frames was collected.

See affected benchmarks

✅ 1 untouched benchmark


Comparing dylanpulver:parse-iso8601-year-only (4103b87) with master (74e7b19)

Open in CodSpeed

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.

1 participant