René's URL Explorer Experiment


Title: gh-124529: Fix `_strptime` to make `%c`/`%x` accept a year with fewer digits by zuo · Pull Request #124778 · python/cpython · GitHub

Open Graph Title: gh-124529: Fix `_strptime` to make `%c`/`%x` accept a year with fewer digits by zuo · Pull Request #124778 · python/cpython

X Title: gh-124529: Fix `_strptime` to make `%c`/`%x` accept a year with fewer digits by zuo · Pull Request #124778 · python/cpython

Description: _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).

Open Graph Description: _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 ...

X Description: _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 ...

Opengraph URL: https://github.com/python/cpython/pull/124778

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:df35a1f5-0789-0ef7-c797-a134db0aca09
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idAFA8:16E4ED:9A5FF4:C1DD13:6B021935
html-safe-nonce6bb472b05397b1d92f74449ab6e6d0a95914c53fb267fa348ad0357a797b9ba4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRkE4OjE2RTRFRDo5QTVGRjQ6QzFERDEzOjZCMDIxOTM1IiwidmlzaXRvcl9pZCI6IjkxNzY0MTU1NTIwNDQ5MzEzODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacb54c1b84e8eb96b206f7efdcf012ed62021817b22693809baa9f3ca043bb5026
hovercard-subject-tagpull_request:2097991689
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/124778/files
twitter:imagehttps://avatars.githubusercontent.com/u/440776?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/440776?s=400&v=4
og:image:alt_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 ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/124778/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F124778%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F124778%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/124778/files
Reloadhttps://github.com/python/cpython/pull/124778/files
Reloadhttps://github.com/python/cpython/pull/124778/files
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
zuohttps://github.com/zuo
python:mainhttps://github.com/python/cpython/tree/main
zuo:strptime-c-and-y-fixhttps://github.com/zuo/cpython/tree/strptime-c-and-y-fix
Conversation 29 https://github.com/python/cpython/pull/124778
Commits 26 https://github.com/python/cpython/pull/124778/commits
Checks 0 https://github.com/python/cpython/pull/124778/checks
Files changed https://github.com/python/cpython/pull/124778/files
Please reload this pagehttps://github.com/python/cpython/pull/124778/files
gh-124529: Fix _strptime to make %c/%x accept a year with fewer digits https://github.com/python/cpython/pull/124778/files#top
Show all changes 26 commits https://github.com/python/cpython/pull/124778/files
827db45 gh-124529: Fix _strptime to make %c/%x accept year with fewer digits zuo Sep 30, 2024 https://github.com/python/cpython/pull/124778/commits/827db4591600305dc1a686ea6a71606366573cc3
1d916a0 Add the blurb zuo Sep 30, 2024 https://github.com/python/cpython/pull/124778/commits/1d916a0392cc7957c74bcb851bec27a771383dd0
a4ba3c9 Fix/improve (and shorten) the blurb zuo Sep 30, 2024 https://github.com/python/cpython/pull/124778/commits/a4ba3c9b866ea5b1f29aac08f5bb692a0cf51292
cef0722 Fix/improve/refactor tests and restrict their scope zuo Sep 30, 2024 https://github.com/python/cpython/pull/124778/commits/cef07220d1118268d0aabad171e83d50d32f96f8
6556bdf Test fail message fixes zuo Sep 30, 2024 https://github.com/python/cpython/pull/124778/commits/6556bdff6f0408d5f407d3566641f890c4c86802
56c84dc Continue enhancing/improving tests zuo Sep 30, 2024 https://github.com/python/cpython/pull/124778/commits/56c84dc69f7886b8926faf57aea59c9fbab56216
b42783c Improve docstring zuo Sep 30, 2024 https://github.com/python/cpython/pull/124778/commits/b42783cb541de081740a8f8d1fc47a98c107f2a6
97b523e Add a suitable mention in the docs + improve blurb zuo Sep 30, 2024 https://github.com/python/cpython/pull/124778/commits/97b523e560749cb0d9a787488f2cf89a37baec9c
6c2addf Docstring edit zuo Sep 30, 2024 https://github.com/python/cpython/pull/124778/commits/6c2addf193279709dc81c209a68e9864bd15eaad
fb32c03 Edit the mention in the docs zuo Sep 30, 2024 https://github.com/python/cpython/pull/124778/commits/fb32c030f05c82cb535e8166f2bb007da0ea3537
722efe4 Minor docs edit zuo Sep 30, 2024 https://github.com/python/cpython/pull/124778/commits/722efe488553aed74c639451c85d66792741cc30
7b46a48 Fix/improve tests zuo Oct 1, 2024 https://github.com/python/cpython/pull/124778/commits/7b46a48f5f7bd8e2dbec6dc8ec7b4442fd5426e6
3d4116a Shorten blurb again zuo Oct 1, 2024 https://github.com/python/cpython/pull/124778/commits/3d4116a44391cca33a8e322b69cf2ccba4a5a581
8eac106 Minor docs edit zuo Oct 1, 2024 https://github.com/python/cpython/pull/124778/commits/8eac1067da9826b8318a6ce6ff4e598f9d86c4d2
1956662 Docstring edit zuo Oct 1, 2024 https://github.com/python/cpython/pull/124778/commits/195666217a8172b7de7906ef8b9b9e88d2f30f9f
a77c3da Docs edit zuo Oct 1, 2024 https://github.com/python/cpython/pull/124778/commits/a77c3da0f74f4f9372d85b39b8c5f8bc2cf7502d
b3b161f Docstring edit zuo Oct 1, 2024 https://github.com/python/cpython/pull/124778/commits/b3b161f16157f392cf534e281cda7568e5fa25f1
949e66a Minor test improvements/refactoring zuo Oct 1, 2024 https://github.com/python/cpython/pull/124778/commits/949e66a1f56173b6e9f80eaa26eb0ca0531996c7
059d4c5 Add `time.strptime()`-dedicated test zuo Oct 1, 2024 https://github.com/python/cpython/pull/124778/commits/059d4c5cacc40708ed75056a45ca8cb8c6d4acd3
95753ac Minor test improvements/refactoring zuo Oct 1, 2024 https://github.com/python/cpython/pull/124778/commits/95753acf1e4113171a431cfacc384e145b9b4b3f
ed4582b Merge branch 'main' into strptime-c-and-y-fix zuo Oct 1, 2024 https://github.com/python/cpython/pull/124778/commits/ed4582be09417cdbc9461e070e164bb6a324cc77
990b075 Minor test improvement zuo Oct 1, 2024 https://github.com/python/cpython/pull/124778/commits/990b0751074e5c35f8c782e212d7e8396e7f79dd
ecc359d Test improvements/refactoring zuo Oct 1, 2024 https://github.com/python/cpython/pull/124778/commits/ecc359de010d06fed3c65197280a33ef46ac31dd
6d690ca Minor refactoring zuo Oct 1, 2024 https://github.com/python/cpython/pull/124778/commits/6d690ca826c76d82058d61083ec43019f3d2c4f6
4ad1062 Merge branch 'main' into strptime-c-and-y-fix zuo Oct 1, 2024 https://github.com/python/cpython/pull/124778/commits/4ad1062033b1c0a0569dfb9174b9c98032c2022c
c79a66b Apply suggestion from @donbarbos zuo Jul 18, 2026 https://github.com/python/cpython/pull/124778/commits/c79a66b29e1b5bb22a8f423a56398a57bea159e2
Clear filters https://github.com/python/cpython/pull/124778/files
Please reload this pagehttps://github.com/python/cpython/pull/124778/files
Please reload this pagehttps://github.com/python/cpython/pull/124778/files
datetime.rst https://github.com/python/cpython/pull/124778/files#diff-591e6aa401ebcd90f71f28b517b3d4437ba293920787df9ed06e037af0b07175
_strptime.py https://github.com/python/cpython/pull/124778/files#diff-c214ba7b6692519554f750422c7c285579aa9e5399b71957a23d8f368be778b7
datetimetester.py https://github.com/python/cpython/pull/124778/files#diff-917d5d1d1423993f37a643afa9f2a2f9caa3c0f91e06c0d7ebea1b879d53b4ef
test_strptime.py https://github.com/python/cpython/pull/124778/files#diff-6608d350ddc7f4ec1a800ae022cb3803725169f47e6878716ea2496670c58c09
test_time.py https://github.com/python/cpython/pull/124778/files#diff-b0b95b7028b45727e52c7fd7c05f5ccd6f1b907496c416a5eacd771f45a20ae8
2024-09-30-04-49-22.gh-issue-124529.hDDlMH.rst https://github.com/python/cpython/pull/124778/files#diff-202fa9442f2f557e34a6f37fadc18d21cc0383ee60de7d3a1c902fb1cef7da33
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L426
Doc/library/datetime.rsthttps://github.com/python/cpython/pull/124778/files#diff-591e6aa401ebcd90f71f28b517b3d4437ba293920787df9ed06e037af0b07175
View file https://github.com/python/cpython/blob/c79a66b29e1b5bb22a8f423a56398a57bea159e2/Doc/library/datetime.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/124778/{{ revealButtonHref }}
https://github.com/python/cpython/pull/124778/files#diff-591e6aa401ebcd90f71f28b517b3d4437ba293920787df9ed06e037af0b07175
https://github.com/python/cpython/pull/124778/files#diff-591e6aa401ebcd90f71f28b517b3d4437ba293920787df9ed06e037af0b07175
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L433
Lib/_strptime.pyhttps://github.com/python/cpython/pull/124778/files#diff-c214ba7b6692519554f750422c7c285579aa9e5399b71957a23d8f368be778b7
View file https://github.com/python/cpython/blob/c79a66b29e1b5bb22a8f423a56398a57bea159e2/Lib/_strptime.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/124778/{{ revealButtonHref }}
https://github.com/python/cpython/pull/124778/files#diff-c214ba7b6692519554f750422c7c285579aa9e5399b71957a23d8f368be778b7
https://github.com/python/cpython/pull/124778/files#diff-c214ba7b6692519554f750422c7c285579aa9e5399b71957a23d8f368be778b7
https://github.com/python/cpython/pull/124778/files#diff-c214ba7b6692519554f750422c7c285579aa9e5399b71957a23d8f368be778b7
https://github.com/python/cpython/pull/124778/files#diff-c214ba7b6692519554f750422c7c285579aa9e5399b71957a23d8f368be778b7
https://github.com/python/cpython/pull/124778/files#diff-c214ba7b6692519554f750422c7c285579aa9e5399b71957a23d8f368be778b7
https://github.com/python/cpython/pull/124778/files#diff-c214ba7b6692519554f750422c7c285579aa9e5399b71957a23d8f368be778b7
https://github.com/python/cpython/pull/124778/files#diff-c214ba7b6692519554f750422c7c285579aa9e5399b71957a23d8f368be778b7
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L434
Lib/test/datetimetester.pyhttps://github.com/python/cpython/pull/124778/files#diff-917d5d1d1423993f37a643afa9f2a2f9caa3c0f91e06c0d7ebea1b879d53b4ef
View file https://github.com/python/cpython/blob/c79a66b29e1b5bb22a8f423a56398a57bea159e2/Lib/test/datetimetester.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/124778/{{ revealButtonHref }}
https://github.com/python/cpython/pull/124778/files#diff-917d5d1d1423993f37a643afa9f2a2f9caa3c0f91e06c0d7ebea1b879d53b4ef
https://github.com/python/cpython/pull/124778/files#diff-917d5d1d1423993f37a643afa9f2a2f9caa3c0f91e06c0d7ebea1b879d53b4ef
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L435
Lib/test/test_strptime.pyhttps://github.com/python/cpython/pull/124778/files#diff-6608d350ddc7f4ec1a800ae022cb3803725169f47e6878716ea2496670c58c09
View file https://github.com/python/cpython/blob/c79a66b29e1b5bb22a8f423a56398a57bea159e2/Lib/test/test_strptime.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/124778/{{ revealButtonHref }}
https://github.com/python/cpython/pull/124778/files#diff-6608d350ddc7f4ec1a800ae022cb3803725169f47e6878716ea2496670c58c09
https://github.com/python/cpython/pull/124778/files#diff-6608d350ddc7f4ec1a800ae022cb3803725169f47e6878716ea2496670c58c09
https://github.com/python/cpython/pull/124778/files#diff-6608d350ddc7f4ec1a800ae022cb3803725169f47e6878716ea2496670c58c09
Please reload this pagehttps://github.com/python/cpython/pull/124778/files
Please reload this pagehttps://github.com/python/cpython/pull/124778/files
https://github.com/python/cpython/pull/124778/files#diff-6608d350ddc7f4ec1a800ae022cb3803725169f47e6878716ea2496670c58c09
Please reload this pagehttps://github.com/python/cpython/pull/124778/files
https://github.com/python/cpython/pull/124778/files#diff-6608d350ddc7f4ec1a800ae022cb3803725169f47e6878716ea2496670c58c09
https://github.com/python/cpython/pull/124778/files#diff-6608d350ddc7f4ec1a800ae022cb3803725169f47e6878716ea2496670c58c09
https://github.com/python/cpython/pull/124778/files#diff-6608d350ddc7f4ec1a800ae022cb3803725169f47e6878716ea2496670c58c09
https://github.com/python/cpython/pull/124778/files#diff-6608d350ddc7f4ec1a800ae022cb3803725169f47e6878716ea2496670c58c09
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L435
Lib/test/test_time.pyhttps://github.com/python/cpython/pull/124778/files#diff-b0b95b7028b45727e52c7fd7c05f5ccd6f1b907496c416a5eacd771f45a20ae8
View file https://github.com/python/cpython/blob/c79a66b29e1b5bb22a8f423a56398a57bea159e2/Lib/test/test_time.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/124778/{{ revealButtonHref }}
https://github.com/python/cpython/pull/124778/files#diff-b0b95b7028b45727e52c7fd7c05f5ccd6f1b907496c416a5eacd771f45a20ae8
https://github.com/python/cpython/pull/124778/files#diff-b0b95b7028b45727e52c7fd7c05f5ccd6f1b907496c416a5eacd771f45a20ae8
Misc/NEWS.d/next/Library/2024-09-30-04-49-22.gh-issue-124529.hDDlMH.rsthttps://github.com/python/cpython/pull/124778/files#diff-202fa9442f2f557e34a6f37fadc18d21cc0383ee60de7d3a1c902fb1cef7da33
View file https://github.com/python/cpython/blob/c79a66b29e1b5bb22a8f423a56398a57bea159e2/Misc/NEWS.d/next/Library/2024-09-30-04-49-22.gh-issue-124529.hDDlMH.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/124778/{{ revealButtonHref }}
Please reload this pagehttps://github.com/python/cpython/pull/124778/files
Please reload this pagehttps://github.com/python/cpython/pull/124778/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.