René's URL Explorer Experiment


Title: datetime.fromisoformat() hits a debug-build assertion on an out-of-range month combined with a 24:00 time · Issue #151770 · python/cpython · GitHub

Open Graph Title: datetime.fromisoformat() hits a debug-build assertion on an out-of-range month combined with a 24:00 time · Issue #151770 · python/cpython

X Title: datetime.fromisoformat() hits a debug-build assertion on an out-of-range month combined with a 24:00 time · Issue #151770 · python/cpython

Description: Bug report datetime.fromisoformat() reaches days_in_month() with month == 0 when the string combines an out-of-range (below 1) month with a 24:00 time, tripping a debug-build assertion. On a release build the same input raises ValueError...

Open Graph Description: Bug report datetime.fromisoformat() reaches days_in_month() with month == 0 when the string combines an out-of-range (below 1) month with a 24:00 time, tripping a debug-build assertion. On a releas...

X Description: Bug report datetime.fromisoformat() reaches days_in_month() with month == 0 when the string combines an out-of-range (below 1) month with a 24:00 time, tripping a debug-build assertion. On a releas...

Opengraph URL: https://github.com/python/cpython/issues/151770

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"datetime.fromisoformat() hits a debug-build assertion on an out-of-range month combined with a 24:00 time","articleBody":"# Bug report\n\n`datetime.fromisoformat()` reaches `days_in_month()` with `month == 0` when the string combines an out-of-range (below 1) month with a `24:00` time, tripping a debug-build assertion. On a release build the same input raises `ValueError`, so the behaviour is inconsistent between build configurations.\n\n## Reproduction\n\n```python\n>>> from datetime import datetime\n>>> datetime.fromisoformat(\"2009-00-01T24:00:00\")\n```\n\nOn a `--with-pydebug` build (C implementation):\n\n```\nAssertion failed: (month >= 1), function days_in_month, file Modules/_datetimemodule.c, line 441.\n```\n\n(SIGABRT). The pure-Python implementation in `Lib/_pydatetime.py` raises `AssertionError` on the same input. On a release / `-DNDEBUG` build, both implementations correctly raise `ValueError: month must be in 1..12, not 0`.\n\n## Root cause\n\nThe `24:00` midnight-rollover guard validates the upper month bound but not the lower one before calling `days_in_month()`:\n\n- `Modules/_datetimemodule.c`, `datetime_datetime_fromisoformat_impl`: `if ((hour == 24) && (month \u003c= 12))`\n- `Lib/_pydatetime.py`, `datetime.fromisoformat`: `if month \u003c= 12 and day \u003c= (days_in_month := _days_in_month(year, month))`\n\nThe parser does not range-check the month before this point, so `month == 0` flows into `days_in_month(year, 0)` and hits `assert(month >= 1)`. The matching upper-bound input `\"2009-13-01T24:00:00\"` is already rejected by the `month \u003c= 12` check; only the lower bound is missing.\n\n## Suggested fix\n\nAdd the `month >= 1` lower bound to the guard in both implementations (mirroring `check_date_args`'s existing `month \u003c 1 || month > 12` validation), so the `24:00` path is only taken for an in-range month and the normal `ValueError` is raised otherwise. I'll open a PR.\n\nThis was found while adding a fuzz harness for `fromisoformat`.\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-151771\n* gh-151809\n* gh-151810\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/tonghuaroot","@type":"Person","name":"tonghuaroot"},"datePublished":"2026-06-20T07:18:35Z","url":"https://github.com/python/cpython/issues/151770"}

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/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:f6550ef5-3162-562d-dfaa-3e6a6129107e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD9A6:215B92:31700FF:41DEC17:6B01EC46
html-safe-noncea74ea0d8e0625e6376f3e71649e128214254dec7e7accf4785f7de469aa496bb
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOUE2OjIxNUI5MjozMTcwMEZGOjQxREVDMTc6NkIwMUVDNDYiLCJ2aXNpdG9yX2lkIjoiNDY1NDYzMjg0MTMyNDM5MTQ5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacd7eab8c69348730a156cfc89602f531017fd4937bb261748db0398ff7dcfac67
hovercard-subject-tagissue:4705546609
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/151770/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f90c88372ad1d486790b8cb08aaece95a269d57aa02d953aa2eabf8891d0eeba/python/cpython/issues/151770
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f90c88372ad1d486790b8cb08aaece95a269d57aa02d953aa2eabf8891d0eeba/python/cpython/issues/151770
og:image:altBug report datetime.fromisoformat() reaches days_in_month() with month == 0 when the string combines an out-of-range (below 1) month with a 24:00 time, tripping a debug-build assertion. On a releas...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernametonghuaroot
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
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
disable-turbofalse
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
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/151770#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F151770
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%2Fissues%2F151770
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/151770
Reloadhttps://github.com/python/cpython/issues/151770
Reloadhttps://github.com/python/cpython/issues/151770
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
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/151770
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/151770
datetime.fromisoformat() hits a debug-build assertion on an out-of-range month combined with a 24:00 timehttps://github.com/python/cpython/issues/151770#top
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/tonghuaroot
tonghuaroothttps://github.com/tonghuaroot
on Jun 20, 2026https://github.com/python/cpython/issues/151770#issue-4705546609
gh-151770: Fix datetime.fromisoformat() assertion on an out-of-range month with a 24:00 time #151771https://github.com/python/cpython/pull/151771
[3.15] gh-151770: Fix datetime.fromisoformat() on an out-of-range month w/ a 24:00 time (GH-151771) #151809https://github.com/python/cpython/pull/151809
[3.14] gh-151770: Fix datetime.fromisoformat() on an out-of-range month w/ a 24:00 time (GH-151771) #151810https://github.com/python/cpython/pull/151810
hugovkhttps://github.com/hugovk
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
on Jun 20, 2026https://github.com/python/cpython/issues/151770#event-26982285701
hugovkhttps://github.com/hugovk
Date and time issues 🕰️https://github.com/orgs/python/projects/21
on Jun 20, 2026https://github.com/python/cpython/issues/151770#event-26982287649
picnixzhttps://github.com/picnixz
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
on Jun 20, 2026https://github.com/python/cpython/issues/151770#event-26983901784
StanFromIrelandhttps://github.com/StanFromIreland
on Jun 20, 2026https://github.com/python/cpython/issues/151770#event-26994046671
gh-151770: Fix `datetime.fromisoformat()` on an out-of-range month w/…https://github.com/python/cpython/commit/1fb874cc076e771c39a7bbc650dce386e3c5b7a0
gh-151770https://github.com/python/cpython/issues/151770
1fb874chttps://github.com/python/cpython/commit/1fb874cc076e771c39a7bbc650dce386e3c5b7a0
[3.14] gh-151770: Fix `datetime.fromisoformat()` on an out-of-range m…https://github.com/python/cpython/commit/9c23ee02e5ae7a8dacc7eb0690a8859d8bf4cef6
gh-151770https://github.com/python/cpython/issues/151770
9c23ee0https://github.com/python/cpython/commit/9c23ee02e5ae7a8dacc7eb0690a8859d8bf4cef6
[3.15] gh-151770: Fix `datetime.fromisoformat()` on an out-of-range m…https://github.com/python/cpython/commit/45a0043971a0f4d1ec586e4fe18cbd6e9a2e2268
gh-151770https://github.com/python/cpython/issues/151770
45a0043https://github.com/python/cpython/commit/45a0043971a0f4d1ec586e4fe18cbd6e9a2e2268
StanFromIrelandhttps://github.com/StanFromIreland
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jun 21, 2026https://github.com/python/cpython/issues/151770#event-27006341136
github-project-automationhttps://github.com/apps/github-project-automation
Date and time issues 🕰️https://github.com/orgs/python/projects/21
on Jun 21, 2026https://github.com/python/cpython/issues/151770
pyctrlhttps://github.com/pyctrl
on Jul 5, 2026https://github.com/python/cpython/issues/151770#event-27578240507
pythongh-151770: Fix `datetime.fromisoformat()` on an out-of-range mo…https://github.com/pyctrl/cpython/commit/a871679f41f9a7d08faf4f9405ee4e7b5e6ccb98
pythongh-151770https://github.com/python/cpython/issues/151770
a871679https://github.com/pyctrl/cpython/commit/a871679f41f9a7d08faf4f9405ee4e7b5e6ccb98
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/151770
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/151770
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
Date and time issues 🕰️https://github.com/orgs/python/projects/21
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.