gh-120713: normalize year with century for datetime.strftime#120820
gh-120713: normalize year with century for datetime.strftime#120820serhiy-storchaka merged 56 commits into
Conversation
reverted unit test
…acing the specifier with "%4Y"
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Note that %G also needs a fix.
Sorry, something went wrong.
Right. It's now accounted for. The calculation of ISO-8601 year for |
Sorry, something went wrong.
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Thank you for addressing my comments.
I think that this is the right way to fix this problem, but we should still get confirmation from other core developers.
The code is much more complicated now with the support of "%G", and the C code has some bugs.
Sorry, something went wrong.
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Thank you so much for taking the time to point me in the right direction! |
Sorry, something went wrong.
|
Thanks @blhsing for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
Sorry, something went wrong.
…ythonGH-120820) (cherry picked from commit 6d34938) Co-authored-by: blhsing <blhsing@gmail.com>
|
Sorry, @blhsing and @serhiy-storchaka, I could not cleanly backport this to |
Sorry, something went wrong.
|
Thank you for your work and patience @blhsing. My apologies for our too picky reviews. |
Sorry, something went wrong.
…time (pythonGH-120820) (cherry picked from commit 6d34938) Co-authored-by: blhsing <blhsing@gmail.com>
…ime.strftime (pythonGH-120820) (pythonGH-121144)" This reverts commit 009618f.
…ime.strftime (pythonGH-120820) (pythonGH-121145)" This reverts commit 027902b.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot AMD64 Ubuntu NoGIL Refleaks 3.13 has failed when building commit 9f6f879. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#builders/1431/builds/335 Failed tests:
Test leaking resources:
Summary of the results of the build (if available): == Click to see traceback logsremote: Enumerating objects: 10, done.
remote: Counting objects: 10% (1/10)
remote: Counting objects: 20% (2/10)
remote: Counting objects: 30% (3/10)
remote: Counting objects: 40% (4/10)
remote: Counting objects: 50% (5/10)
remote: Counting objects: 60% (6/10)
remote: Counting objects: 70% (7/10)
remote: Counting objects: 80% (8/10)
remote: Counting objects: 90% (9/10)
remote: Counting objects: 100% (10/10)
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 12% (1/8)
remote: Compressing objects: 25% (2/8)
remote: Compressing objects: 37% (3/8)
remote: Compressing objects: 50% (4/8)
remote: Compressing objects: 62% (5/8)
remote: Compressing objects: 75% (6/8)
remote: Compressing objects: 87% (7/8)
remote: Compressing objects: 100% (8/8)
remote: Compressing objects: 100% (8/8), done.
remote: Total 10 (delta 2), reused 5 (delta 2), pack-reused 0
From https://github.com/python/cpython
* branch 3.13 -> FETCH_HEAD
Note: switching to '9f6f8790ef39fd035f6ada1a9dfcb47d58d08fea'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 9f6f8790ef Revert "[3.13] gh-120713: Normalize year with century for datetime.strftime (GH-120820) (GH-121144)" (GH-122408)
Switched to and reset branch '3.13'
configure: WARNING: no system libmpdecimal found; falling back to bundled libmpdecimal (deprecated and scheduled for removal in Python 3.15)
make: *** [Makefile:2264: buildbottest] Error 2 |
Sorry, something went wrong.
On some platforms such as Linux,
datetime.strftimedoes not 0-pad a year <= 999 when formatting with'%Y'despite the documentation claiming an example output of "0001, 0002, …". The same issue applies when formatting with"%G".This PR fixes the issue by formatting a year with century with
'%04ld'usingsprintf(in C) or'{:04}'usingstr.format(in Python) if the platform is found to show the aforementioned behavior.datetime.strftime("%Y")is not padding correctly #120713