The Wayback Machine - https://web.archive.org/web/20260223072430/https://github.com/python/cpython/pull/145018
Skip to content

Comments

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

Open
F0RRZZ wants to merge 2 commits intopython:mainfrom
F0RRZZ:issue-137165-unify-invalid-zp-behaviour
Open

gh-137165: Unify datetime.strftime behavior for unsupported non-zero-padded specifiers#145018
F0RRZZ wants to merge 2 commits intopython:mainfrom
F0RRZZ:issue-137165-unify-invalid-zp-behaviour

Conversation

@F0RRZZ
Copy link
Contributor

@F0RRZZ F0RRZZ commented Feb 19, 2026 •

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant