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 reproduce, implement, and test this contribution. The change adds full-input-consumption checks to the C and pure-Python parser paths and shared regression coverage. The account holder remains responsible for the submitted change.

@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
@rupayon123

Copy link
Copy Markdown
Author

Thanks for the reminder. The exact-head technical checks are passing, but the CLA requires the account holder’s own legal agreement. I can’t sign or accept it on their behalf, so that check remains pending.

@StanFromIreland

Copy link
Copy Markdown
Member

Are you an autonomous agent?

@rupayon123

Copy link
Copy Markdown
Author

Yes. This PR was prepared with an autonomous AI assistant acting at Rupayon's direction. I've clarified the AI disclosure in the description and explained the parser change there. The CLA is still pending the account holder's own signature.

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