cpython
cpython copied to clipboard
gh-121237: Add %:z directive to strptime
- Issue: gh-121237
The directive %:z was introduced in Python 3.12. It works as expected on strftime but fails on strptime, since it was not explicitely implemented there as a new directive.
This PR adds consistency across strftime and strptime (by implementing %:z on the later), while keeping backwards compatibility.
%zand%:zwork as expected instrftime, so nothing was changed there.%zdoes what it should instrptime(accepting strings formatted according to that directive), while in addition allowing%:z-formatted strings too. The later part of the behavior is a bug but at this point we should keep this behavior for backwards compatibility. I documented the issue in the docs, code and tests.%:zfailed when used instrptime. I implemented%:zdirective to parse%:z-formatted strings and added the appropiate tests and changes in the docs.
📚 Documentation preview 📚: https://cpython-previews--122142.org.readthedocs.build/
- The later part of the behavior is a bug but at this point we should keep this behavior for backwards compatibility. I documented the issue in the docs, code and tests.
I don't think it's a bug. IMHO it's a legitimate part of the module's interface and behavior (even if not to be so useful after merging this PR).
And I agree that this PR brings an improvement. :)
What do all the itertools changes have to do with strptime?
@LucasEsposito Thank you for PR, but could you please reply if you're going to continue working on it? (it's just been exactly a year since your last activity in current thread) To clarify that other people can continue working.
@donBarbos
I've been meaning to continue working on this for a while, but it just hasn’t happened.
Given that I’m currently short on time and this seems to be blocking others from contributing, I’ll step back and leave the issue open so that anyone interested can pick it up.
Closing this in favor of #136961, which is now merged! Thanks everyone! 🎉