Skip to content

Parse UTC designators in from_format offset tokens - #1084

Open
Sskift wants to merge 1 commit into
python-pendulum:masterfrom
Sskift:fix/from-format-utc-designator
Open

Sskift wants to merge 1 commit into
python-pendulum:masterfrom
Sskift:fix/from-format-utc-designator

Conversation

@Sskift

@Sskift Sskift commented Nov 2, 2026

Copy link
Copy Markdown

The Z and ZZ offset tokens already accept Z and z in their regular expressions, but from_format() then tries to parse them as numeric offsets. For example, parsing 1975-05-21T22:32:11Z with YYYY-MM-DD[T]HH:mm:ssZ fails with ValueError: invalid literal for int() with base 10: ''.

Normalize the accepted UTC designators to +00:00 before the existing offset conversion. Tests cover both token forms, both designator cases, numeric-zero controls, and an explicit non-UTC default timezone.

Validation on Windows / CPython 3.12 using the pure-Python source: 8 failures and 8 passing controls before the change; all 16 pass afterward. The full suite has 1,883 passes, 5 skips and the existing timezone-name failure in test_instance_with_aware_datetime_any_tzinfo. Mypy on the changed source and all applicable pinned prek hooks pass; the Rust hook has no matching changed files. The Rust extension was not built locally.

  • Added tests for changed code.
  • Updated documentation for changed code. This makes the existing token grammar work as specified without adding a format token.

This contribution was prepared with Codex assistance.

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