Title: Pure-Python datetime.fromisoformat() accepts a trailing date-time separator · Issue #160850 · python/cpython · GitHub
Open Graph Title: Pure-Python datetime.fromisoformat() accepts a trailing date-time separator · Issue #160850 · python/cpython
X Title: Pure-Python datetime.fromisoformat() accepts a trailing date-time separator · Issue #160850 · python/cpython
Description: Bug report Title: Pure-Python datetime.fromisoformat() accepts a trailing date-time separator Bug report Bug description: The pure-Python datetime.fromisoformat() (Lib/_pydatetime.py) accepts a string that ends with the date-time separat...
Open Graph Description: Bug report Title: Pure-Python datetime.fromisoformat() accepts a trailing date-time separator Bug report Bug description: The pure-Python datetime.fromisoformat() (Lib/_pydatetime.py) accepts a str...
X Description: Bug report Title: Pure-Python datetime.fromisoformat() accepts a trailing date-time separator Bug report Bug description: The pure-Python datetime.fromisoformat() (Lib/_pydatetime.py) accepts a str...
Opengraph URL: https://github.com/python/cpython/issues/160850
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Pure-Python datetime.fromisoformat() accepts a trailing date-time separator","articleBody":"### Bug report\n\nTitle: Pure-Python `datetime.fromisoformat()` accepts a trailing date-time separator\n\n# Bug report\n\n### Bug description:\n\nThe pure-Python `datetime.fromisoformat()` (`Lib/_pydatetime.py`) accepts a string that ends with the date-time separator and has no time after it, and returns midnight. The C implementation raises `ValueError`:\n\n```python\n>>> import datetime, _pydatetime\n>>> datetime.datetime.fromisoformat('2009-04-19T')\nTraceback (most recent call last):\n ...\nValueError: Invalid isoformat string: '2009-04-19T'\n>>> _pydatetime.datetime.fromisoformat('2009-04-19T')\ndatetime.datetime(2009, 4, 19, 0, 0)\n>>> _pydatetime.datetime.fromisoformat('2009-04-19 ')\ndatetime.datetime(2009, 4, 19, 0, 0)\n```\n\nThe same happens with basic and week dates (`'20090419T'`, `'2009-W16-7T'`).\n\n`fromisoformat()` splits the string at the separator and then only parses the time part `if tstr:`, so an empty time part makes it fall back to the date-only path. The C version (`datetime_fromisoformat()`) only takes the date-only path when nothing follows the date (`len > separator_location`) and otherwise passes the empty time to the time parser, which rejects it.\n\nThis matters for PyPy and other implementations that use `_pydatetime`.\n\n### CPython versions tested on:\n\n3.14, 3.15, CPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\n### CPython versions tested on:\n\n3.14, 3.15, CPython main branch\n\n### Operating systems tested on:\n\nLinux","author":{"url":"https://github.com/Krish0703-irl","@type":"Person","name":"Krish0703-irl"},"datePublished":"2026-10-28T20:39:40Z","url":"https://github.com/python/cpython/issues/160850"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ff06da7c-13a2-3b52-680e-6cdf9d08b3bb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D25C:97D39:E1E7EF:12A20A4:6B02025A |
| html-safe-nonce | 3e4d2403d9ff89a516e9a0721854786d193da807209df7e39a9bb99ab41fabe9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjVDOjk3RDM5OkUxRTdFRjoxMkEyMEE0OjZCMDIwMjVBIiwidmlzaXRvcl9pZCI6IjU5MTIwMTM5MjA1NzQ1MDU1NjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 106d76c3db993551559359958bd5a71ab22a3bf1b70e7a12efd373c64db375bd |
| hovercard-subject-tag | issue:6087085625 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/160850/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b7a62e76ae09ac51c7fee1ddde2f688652677cffc85eae8bff26398662bc11c5/python/cpython/issues/160850 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b7a62e76ae09ac51c7fee1ddde2f688652677cffc85eae8bff26398662bc11c5/python/cpython/issues/160850 |
| og:image:alt | Bug report Title: Pure-Python datetime.fromisoformat() accepts a trailing date-time separator Bug report Bug description: The pure-Python datetime.fromisoformat() (Lib/_pydatetime.py) accepts a str... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Krish0703-irl |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width