Uh oh!
There was an error while loading. Please reload this page.
gh-124529: Fix _strptime to make %c/%x accept a year with fewer digits - #124778
gh-124529: Fix _strptime to make %c/%x accept a year with fewer digits#124778zuo wants to merge 26 commits into
_strptime to make %c/%x accept a year with fewer digits#124778Conversation
33d5109 to
d3ae17bCompare_strptime to make %c/%y accept a year with fewer digits_strptime to make %c/%x accept a year with fewer digitsd3ae17b to
91b6bcaCompare91b6bca to
1d916a0CompareUh oh!
There was an error while loading. Please reload this page.
bce4b6d to
56c84dcCompareUh oh!
There was an error while loading. Please reload this page.
PS Note that the changes concern only the |
PPS I added (obviously) the necessary tests (directly related to the changes), but also some indirectly-related ones (especially confirming the unchanged behavior for PPPS A suitable mention in the docs has also been added. |
|
zuo
commented
Oct 1, 2024
OK, I hope now it's ready. :) |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
zuo
commented
Oct 4, 2024
TODO: if this PR's approach is accepted at all, it would be good to adjust it to the changes from PR #124946 (after it is merged). |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
donbarbos
commented
Feb 27, 2025
looks like good idea and important fix :) |
zuo
commented
Mar 3, 2025
Yes, I am :) Yet I'm not sure what is the next step... |
Uh oh!
There was an error while loading. Please reload this page.
StanFromIreland
commented
Feb 28, 2026
This has a lot of conflicts, and needs updates. |
This PR is stale because it has been open for 30 days with no activity. |
Co-authored-by: Semyon Moroz <donbarbos@proton.me>
For the record, I'd be happy to continue with this, but I guess first the discussion in the related issue (#124529) needs to be resolved -- to decide whether this path is OK or not. |
_strptime.TimeREhas been modified, regarding the%cand%xformatcodes, to make
datetime.datetime.strptime(),datetime.date.strptime()and
time.strptime()accept inputs that contain year numbers consistingof fewer digits than usual, i.e., not zero-padded to the usual width
of 2 or 4 (which is appropriate for the format code and current locale).
Thanks to that, now the desired behavior described in gh-124529 should be
consistently observed; certain
strftime/strptimeround trips (involving%c/%xand small year numbers) no longer raiseValueErrorfor someplatforms/locales (in particular, this was the case on Linux, for various
locales, including
C/C.UTF-8).