| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Thanks @tonghuaroot for the PR, and @StanFromIreland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15. |
Sorry, something went wrong.
|
GH-152425 is a backport of this pull request to the 3.15 branch. |
Sorry, something went wrong.
|
GH-152426 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
_wrap_strftime in the pure-Python datetime implementation reads
object.year in its year-normalization branch. When strftime is called on a
datetime.time (which has no .year), this raises
AttributeError: 'time' object has no attribute 'year' for the %Y, %G, %C
and %F directives. The crash happens in the branch guard itself, before the
_need_normalize_century() platform check, so it occurs on every platform.
The C accelerator is correct: a time has no date, so strftime fills the
1900-01-01 placeholder and returns '1900', '19', '1900-01-01' and '1900'
respectively.
The year being formatted is timetuple[0], which is 1900 for a time and
object.year for a date/datetime. This replaces object.year with
timetuple[0] at both occurrences, fixing time and leaving date/datetime
behaviour unchanged: the new pure-Python output equals the long-standing C
accelerator output.
Tests in TestTime.test_strftime assert the four directives, and run under both
the C and pure implementations via the test_datetime parametrization.