GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-124529: Fix `_strptime` to make `%c`/`%x` accept a year with fewer digits by zuo · Pull Request #124778 · python/cpython

Conversation

@zuo

@zuo zuo commented Sep 30, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

_strptime.TimeRE has been modified, regarding the %c and %x format
codes, to make datetime.datetime.strptime(), datetime.date.strptime()
and time.strptime() accept inputs that contain year numbers consisting
of 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/strptime round trips (involving
%c/%x and small year numbers) no longer raise ValueError for some
platforms/locales (in particular, this was the case on Linux, for various
locales, including C/C.UTF-8).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@zuo
zuo requested review from abalkin and pganssle as code owners September 30, 2024 02:19
@bedevere-app bedevere-app Bot added the awaiting review label Sep 30, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Sep 30, 2024
datetime.strptime(dt.strftime("%c"), "%c")) fails when year is <1000. #124529
Open
@zuo
zuo force-pushed the strptime-c-and-y-fix branch from 33d5109 to d3ae17b Compare September 30, 2024 02:51
@zuo zuo changed the title gh-124529: Fix _strptime to make %c/%y accept a year with fewer digits gh-124529: Fix _strptime to make %c/%x accept a year with fewer digits Sep 30, 2024
@zuo
pythongh-124529: Fix _strptime to make %c/%x accept year with fewer d…
827db45
…igits
@zuo
zuo force-pushed the strptime-c-and-y-fix branch from d3ae17b to 91b6bca Compare September 30, 2024 02:52
@zuo
Add the blurb
1d916a0
@zuo
zuo force-pushed the strptime-c-and-y-fix branch from 91b6bca to 1d916a0 Compare September 30, 2024 02:54
rruuaanng
rruuaanng reviewed Sep 30, 2024
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2024-09-30-04-49-22.gh-issue-124529.hDDlMH.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

zuo added 2 commits September 30, 2024 16:29
@zuo
Fix/improve (and shorten) the blurb
a4ba3c9
@zuo
Fix/improve/refactor tests and restrict their scope
cef0722
@zuo
zuo requested a review from rruuaanng September 30, 2024 19:01
zuo added 2 commits September 30, 2024 21:06
@zuo
Test fail message fixes
6556bdf
@zuo
Continue enhancing/improving tests
56c84dc
@zuo
zuo force-pushed the strptime-c-and-y-fix branch from bce4b6d to 56c84dc Compare September 30, 2024 20:44
zuo added 5 commits September 30, 2024 22:58
@zuo
Improve docstring
b42783c
@zuo
Add a suitable mention in the docs + improve blurb
97b523e
@zuo
Docstring edit
6c2addf
@zuo
Edit the mention in the docs
fb32c03
@zuo
Minor docs edit
722efe4
rruuaanng
rruuaanng reviewed Oct 1, 2024
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2024-09-30-04-49-22.gh-issue-124529.hDDlMH.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

zuo added 2 commits October 1, 2024 04:29
@zuo
Fix/improve tests
7b46a48
@zuo
Shorten blurb again
3d4116a
@zuo

zuo commented Oct 1, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

PS Note that the changes concern only the %c/%x-parsing-related behavior, and nothing changes when it comes to %y, %Y and %G (and any non-standard year-representation-related format codes).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zuo

zuo commented Oct 1, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

PPS I added (obviously) the necessary tests (directly related to the changes), but also some indirectly-related ones (especially confirming the unchanged behavior for %y/%Y/%G).

PPPS A suitable mention in the docs has also been added.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zuo
zuo requested a review from rruuaanng October 1, 2024 13:23
zuo added 2 commits October 1, 2024 16:09
@zuo
Minor docs edit
8eac106
@zuo
Docstring edit
1956662
zuo added 2 commits October 1, 2024 16:35
@zuo
Docs edit
a77c3da
@zuo
Docstring edit
b3b161f
@zuo

zuo commented Oct 1, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I hope it's ready. [EDIT: not yet]

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

zuo added 2 commits October 1, 2024 22:32
@zuo
Minor test improvements/refactoring
949e66a
@zuo
Add time.strptime()-dedicated test
059d4c5
@zuo
zuo force-pushed the strptime-c-and-y-fix branch from c16b5e3 to 059d4c5 Compare October 1, 2024 20:33
zuo added 4 commits October 1, 2024 22:42
@zuo
Minor test improvements/refactoring
95753ac
@zuo
Merge branch 'main' into strptime-c-and-y-fix
ed4582b
@zuo
Minor test improvement
990b075
@zuo
Test improvements/refactoring
ecc359d
@zuo

zuo commented Oct 1, 2024

Copy link
Copy Markdown
Contributor Author

OK, I hope now it's ready. :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

zuo added 2 commits October 2, 2024 00:28
@zuo
Minor refactoring
6d690ca
@zuo
Merge branch 'main' into strptime-c-and-y-fix
4ad1062
rruuaanng
rruuaanng reviewed Oct 1, 2024
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2024-09-30-04-49-22.gh-issue-124529.hDDlMH.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_strptime.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@zuo

zuo commented Oct 4, 2024

Copy link
Copy Markdown
Contributor Author

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).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zuo
zuo requested a review from rruuaanng October 11, 2024 05:10
rruuaanng
rruuaanng reviewed Oct 11, 2024
View reviewed changes
Comment thread Lib/test/test_strptime.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_strptime.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@donbarbos

donbarbos commented Feb 27, 2025

Copy link
Copy Markdown
Contributor

looks like good idea and important fix :)
@zuo are you ready to continue?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zuo
zuo requested a review from rruuaanng March 3, 2025 02:46
@zuo

zuo commented Mar 3, 2025

Copy link
Copy Markdown
Contributor Author

looks like good idea and important fix :) @zuo are you ready to continue?

Yes, I am :)

Yet I'm not sure what is the next step...

donbarbos reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

donbarbos
donbarbos reviewed Mar 3, 2025
View reviewed changes
Comment thread Doc/library/datetime.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@StanFromIreland

StanFromIreland commented Feb 28, 2026

Copy link
Copy Markdown
Member

This has a lot of conflicts, and needs updates.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Apr 18, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 18, 2026
@zuo @donbarbos
Apply suggestion from @donbarbos
c79a66b
Co-authored-by: Semyon Moroz <[email protected]>
@zuo
zuo requested a review from StanFromIreland as a code owner July 18, 2026 13:08
@zuo

zuo commented Jul 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Jul 22, 2026
@github-actions

github-actions Bot commented Oct 25, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@pganssle pganssle Awaiting requested review from pganssle pganssle is a code owner
@abalkin abalkin Awaiting requested review from abalkin
@rruuaanng rruuaanng Awaiting requested review from rruuaanng
@StanFromIreland StanFromIreland Awaiting requested review from StanFromIreland StanFromIreland is a code owner
1 more reviewer
@donbarbos donbarbos donbarbos left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@zuo @donbarbos @StanFromIreland @rruuaanng
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.