Skip to content

Reject nonpositive interval range amounts - #1066

Open
FanWu-ai wants to merge 1 commit into
python-pendulum:masterfrom
FanWu-ai:fix/nonpositive-interval-range
Open

FanWu-ai wants to merge 1 commit into
python-pendulum:masterfrom
FanWu-ai:fix/nonpositive-interval-range

Conversation

@FanWu-ai

Copy link
Copy Markdown
Contributor

Summary

Interval.range("days", 0) yields the same start forever. A negative amount advances away from the end rather than toward it, so a normal list(...) call continues until date overflow. Inverted intervals already select their own direction and are affected too.

Reject zero and negative amounts with ValueError before yielding any dates. Positive steps and interval-defined direction are unchanged. Tests cover forward/reverse and absolute intervals, date/datetime inputs, single-point intervals and positive step controls. Document the positive-amount requirement and generator validation timing.

Verification

Linux x86_64 / CPython 3.12.14, upstream e06dacedc4cdea90fa1286b3965d180ab94cf251:

  • Pristine full suite: 1,871 passed, 3 skipped with both pure-Python and newly built native Rust backends.
  • Final regression tests against pristine source: 26 failed, 16 passed.
  • Fixed full suite: 1,913 passed, 3 skipped with each backend (42 new regression/control cases).
  • Full Mypy: passed across 229 files.
  • prek run --all-files: all six hooks passed, including Ruff and Rust formatting/clippy.
  • mkdocs build --strict -f docs/mkdocs.yml: passed; the same six pre-existing informational anchor notices appear on the pristine build.
  • git diff --check: passed.
  • Additional independent checks: 1,000 randomized positive-step controls against stdlib range passed.

The unchanged skips are one Windows-only test and two existing unsupported zoneinfo POSIX-transition cases. Native-extension loading was verified. Other operating systems and Python versions were not tested locally. Hosted CI is not claimed passed.

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code.

Prepared and tested with OpenAI Codex assistance, including automated review. No human review is claimed.

@FanWu-ai
FanWu-ai marked this pull request as ready for review October 20, 2026 21:39
@codspeed

codspeed Bot commented Oct 20, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

ℹ️ 1 benchmark has no flamegraph

The flamegraph could not be generated because we failed to resolve the symbols in the profiling trace. This happens when we fail to harvest information about language frames.

✅ 1 untouched benchmark


Comparing FanWu-ai:fix/nonpositive-interval-range (c5e7814) with master (e06dace)

Open in CodSpeed

This branch has not been deployed

No deployments
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.

1 participant