Skip to content

gh-158500: Reject trailing characters in date.fromisoformat - #158557

Draft
rupayon123 wants to merge 2 commits into
python:mainfrom
rupayon123:fix-date-fromisoformat-trailing-data-20261001
Draft

rupayon123 wants to merge 2 commits into
python:mainfrom
rupayon123:fix-date-fromisoformat-trailing-data-20261001

Conversation

@rupayon123

@rupayon123 rupayon123 commented Oct 1, 2026 •

Copy link
Copy Markdown

Fixes #158500.

date.fromisoformat() currently accepts basic-format date and ISO-week strings with extra trailing characters because both parsers stop after their expected fields without checking that the input was fully consumed. Require complete input consumption in the C and pure-Python implementations, and cover both forms in the shared regression tests.

Validation:

  • Reproduced the bug before the change on CPython 3.11.15's C parser and the main-branch pure-Python parser.
  • ./python.exe -m test test_datetime --match '*fromisoformat*' passed (122 tests).
  • ./python.exe -m test test_datetime passed (1,166 tests, 33 skipped), exercising both pure-Python and accelerated datetime implementations.
  • git diff --cached --check and CPython Tools/patchcheck/patchcheck.py passed.

The debug build completed but this machine lacks OpenSSL and several unrelated optional modules; the datetime tests above passed. AI assistance was used to prepare this contribution; I reviewed the diff and remain responsible for it.

@python-cla-bot

python-cla-bot Bot commented Oct 1, 2026

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@StanFromIreland

Copy link
Copy Markdown
Member

Please sign the CLA.

@StanFromIreland
StanFromIreland marked this pull request as draft October 1, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

date.fromisoformat() silently ignores the last two characters of a 10-character basic-format string

2 participants