Skip to content

Reject invalid ISO week dates#1489

Open
Sean-Kenneth-Doherty wants to merge 3 commits into
dateutil:masterfrom
Sean-Kenneth-Doherty:fix-invalid-iso-week-53
Open

Reject invalid ISO week dates#1489
Sean-Kenneth-Doherty wants to merge 3 commits into
dateutil:masterfrom
Sean-Kenneth-Doherty:fix-invalid-iso-week-53

Conversation

@Sean-Kenneth-Doherty
Copy link
Copy Markdown

@Sean-Kenneth-Doherty Sean-Kenneth-Doherty commented May 17, 2026

Fixes #1236.

Summary

  • Reject ISO week dates when the computed date belongs to a different ISO year/week/day than requested.
  • Add invalid 2021-W53 coverage for dashed and compact week-date forms.
  • Preserve existing valid week 53 behavior for years that actually have week 53.
  • Ignore external documentation links that currently fail CI linkcheck for automated checkers.

Tests

  • PYTHONPATH=src python - <<'PY' ... checked 2021-W53, 2021-W53-1, 2021W53, and 2021W531 now raise while valid 2020-W53 forms still parse.
  • PYTHONPATH=src uv run --no-project --with pytest --with pytest-cov --with six --with hypothesis python -m pytest tests/test_isoparser.py tests/property/test_isoparse_prop.py -q
  • PYTHONPATH=src python -m compileall -q src/dateutil/parser/isoparser.py tests/test_isoparser.py
  • python -m py_compile docs/conf.py
  • uv run --no-project --with pre-commit pre-commit run --files src/dateutil/parser/isoparser.py tests/test_isoparser.py
  • git diff --check

I also tried the full tests suite with the same ephemeral uv environment. The parser change was not implicated, but local collection/execution failed in timezone tests because this source checkout does not include src/dateutil/zoneinfo/dateutil-zoneinfo.tar.gz.

@Sean-Kenneth-Doherty
Copy link
Copy Markdown
Author

The Python/platform test matrix for this parser change is passing. The prior red docs job was from Sphinx linkcheck hitting external URLs (timeanddate.com, gnu.org, and pds-rings.seti.org), not from the ISO week change. I split that CI hardening into #1490, which is green now, so this PR can stay focused on fixing #1236.

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.

dateutil accepts none-existent week 53

1 participant