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
d3ae17b
Compare
_strptime to make %c/%y accept a year with fewer digits_strptime to make %c/%x accept a year with fewer digits
d3ae17b to
91b6bca
Compare
91b6bca to
1d916a0
Compare
bce4b6d to
56c84dc
Compare
|
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. |
|
|
c16b5e3 to
059d4c5
Compare
|
OK, I hope now it's ready. :) |
|
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). |
|
looks like good idea and important fix :) |
Yes, I am :) Yet I'm not sure what is the next step... |
|
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).