Skip to content

gh-137165: Unify datetime.strftime behavior for unsupported non-zero-padded specifiers - #145018

Open
F0RRZZ wants to merge 5 commits into
python:mainfrom
F0RRZZ:issue-137165-unify-invalid-zp-behaviour
Open

F0RRZZ wants to merge 5 commits into
python:mainfrom
F0RRZZ:issue-137165-unify-invalid-zp-behaviour

Conversation

@F0RRZZ

@F0RRZZ F0RRZZ commented Feb 19, 2026 •

Copy link
Copy Markdown
Contributor

This PR unifies the behavior of datetime.strftime when encountering unsupported or invalid non-zero-padded specifiers across different platforms.

Previously, the behavior for invalid specifiers was inconsistent:
Windows: Raised a ValueError
macOS/FreeBSD: Could return partial strings or stripped characters (e.g., returning # instead of %-#).
Linux: Echoes the specifier back as-is (e.g., %-#).

The behavior is now unified to match Linux.

@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 7, 2026
ambv added 2 commits October 21, 2026 03:03
Co-authored-by: Muse Code (Meta Muse Spark)
Co-authored-by: Muse Code (Meta Muse Spark)
@ambv
ambv requested a review from StanFromIreland as a code owner October 21, 2026 01:03
@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Oct 21, 2026
@python-cla-bot

python-cla-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

strchr() and (char) narrowing misclassified non-ASCII conversions:
characters like U+0164 (low byte 'd') were passed through to the
platform strftime, U+0080-U+00FF raised OverflowError, and the rest
were echoed as mojibake.  Only ASCII can name a conversion, so echo
anything else back literally with the full code point, matching the
pure-Python implementation.  Add regression tests.

Co-authored-by: Muse Code (Meta Muse Spark)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review stale Stale PR or inactive for long period of time. type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants