Skip to content

Validate reprioritization weights before creating implicit parents - #154

Open
Aschenbath wants to merge 1 commit into
python-hyper:masterfrom
Aschenbath:fix/oss20-20261125-3592-priority-invalid-reprioritize
Open

Aschenbath wants to merge 1 commit into
python-hyper:masterfrom
Aschenbath:fix/oss20-20261125-3592-priority-invalid-reprioritize

Conversation

@Aschenbath

Copy link
Copy Markdown

Calling reprioritize(1, depends_on=3, weight=0) creates stream 3 before raising BadWeightError. The rejected operation therefore consumes a stream slot and introduces an active stream into scheduling.

Share the existing weight validation between the setter and reprioritization, and validate before creating an implicit parent. Apply the new weight only after resolving the parent so capacity errors still leave the original weight intact. The self-dependency error keeps its existing precedence.

Eight regressions fail on the original source and pass after the fix, covering invalid types/ranges and both exclusive modes. Two additional controls check that a parent-capacity failure preserves the old weight.

Validation on Windows/Python 3.12.12: 180 tests passed, with 100% statement and branch coverage. Flake8, mypy, Sphinx with -W, wheel/sdist builds, check-manifest, twine check, and git diff --check passed. Black 26.10.1 still reports the same two pre-existing blank-line differences in src/priority/__init__.py and the test imports, verified on the unchanged baseline; the changed implementation is formatted.

AI assistance disclosure: an AI coding assistant prepared the patch, reproduced the mutation after failure, and ran the listed checks.

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