Skip to content

fix: prevent internal errors from non-finite rerun delays - #391

Open
Arham-Begani wants to merge 1 commit into
pytest-dev:masterfrom
Arham-Begani:fix/nonfinite-rerun-delays
Open

Arham-Begani wants to merge 1 commit into
pytest-dev:masterfrom
Arham-Begani:fix/nonfinite-rerun-delays

Conversation

@Arham-Begani

@Arham-Begani Arham-Begani commented Oct 18, 2026 •

Copy link
Copy Markdown

Closes #390.

Problem

float() and the CLI's float argument parser accept NaN and infinity. The delay getters currently reject negative values but pass these non-finite values to the retry calculation and time.sleep, aborting the session with INTERNALERROR / exit code 3.

For example, a test that passes on its third execution never completes with --reruns 2 --reruns-delay=nan. Both non-finite delay values and non-finite backoff factors reproduce the problem. See #390 for four real-sleep commands and observed exceptions.

Changes

  • Validate finiteness in both getters after resolving CLI / ini / marker precedence.
  • Warn and use the existing defaults (delay 0, backoff factor 1.0), consistent with the existing negative-value fallback. Keep existing negative-value handling and diagnostics.
  • Add 16 parametrized regressions covering NaN and positive infinity in both settings through CLI, ini, keyword markers and positional markers. Each test verifies third-attempt recovery, rerun counts, normal exit status and the warning.
  • Add the issue-numbered changelog fragment.

The retry formula is unchanged. This fixes explicit non-finite input; it does not duplicate #389's separate large-finite-factor overflow fix.

Validation

Windows, CPython 3.13.15, pytest 9.1.1, pytest-xdist 3.8.0:

  • All 16 new regressions failed against unmodified master 01fd226bd533ecd7f6aabe7c155c4ca7bcd8598c; all 16 pass with this patch.
  • Four real CLI / real time.sleep reproductions changed from INTERNALERROR / exit 3 to 1 passed, 2 rerun / exit 0.
  • Full suite, including xdist tests: 274 passed (pytest -vv -o faulthandler_timeout=30 tests/). An initial quiet run stopped making progress and was terminated; the diagnostic rerun completed without failures or timeout traces in 83.14 seconds.
  • All nine pinned pre-commit run --all-files --show-diff-on-failure checks passed; commit hooks passed on changed files.
  • towncrier check --compare-with origin/master and git diff --check passed.
  • Supplemental mypy check passes with --ignore-missing-imports. Without that flag, this environment reports missing imports for exceptiongroup and _pytest.nodeid; this is not claimed as a clean unrestricted type check.

Fork CI at the submitted commit a2494ae697fbc2fe439cc4b0538ff3877ded4423 completed successfully: all 41 test jobs passed, covering the Python/pytest matrix, PyPy, xdist, free-threaded Python, Linux, Windows and macOS. The docs workflow also passed. Results:

Upstream Actions currently reports action_required for its four workflows and needs maintainer approval to run. The upstream Read the Docs preview passed. Fork success is reported separately from upstream CI and maintainer acceptance.

AI assistance

An AI coding assistant investigated, implemented, tested and drafted this contribution with the account owner's authorization. No personal human review or authorship certification is claimed. Maintainer review is welcome.

@Arham-Begani

Copy link
Copy Markdown
Author

Could a maintainer approve the pending upstream Actions runs when convenient? The submitted head is a2494ae697fbc2fe439cc4b0538ff3877ded4423; its fork validation passed all 41 matrix jobs, including PyPy, xdist, free-threaded Python and Linux/Windows/macOS (test matrix, additional workflow). The upstream documentation preview also passes.

Upstream CI approval and code review are still pending. The PR's existing description separates these fork results from upstream validation and records the 16 before/after regressions. No source changes were made for this follow-up.

This comment was prepared with OpenAI Codex assistance.

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.

Non-finite rerun delay settings abort pytest with INTERNALERROR

1 participant