Repository navigation
Require Python 3.11 and say so before tomllib fails - #1916
Merged
Merged
Conversation
The selector, the release generator and the Bug origin regressions helper exit with one line naming the version found, the version needed and the interpreter, in place of an import traceback 30-50 minutes into the suite. docs/testing.md names the minimum. Closes #1896
Name the one tomllib helper the Rust tests start, state 3.11 in the TypeScript prototype row, and comment why the guard precedes tomllib.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two scripts import
tomllib, which needs Python 3.11: the Bug origin regressions helper and the release generator. Before this change, apython3of 3.9 or 3.10 caused two problems:scripts/affected-testsran the full Rust suite anyway.settlement::historical_review_and_reclosed_origin_regressionsthen failed only when the suite ended, with an import traceback.Now all three scripts refuse an older interpreter at once, using the same single line:
The check is copied into each script, not shared. The issue asked for sharing only "if sharing stays simple". The scripts live in two directories, and the check has to run before
import tomllib, so a shared module would mean editingsys.pathbefore any import. Tests pin the exact message in every copy.The tests fake older interpreters: they set
sys.version_infoand run each script throughrunpy. A separateast.parse(..., feature_version=(3, 9))check ensures the scripts still parse far enough on 3.9 to print the message.Closes #1896
Evidence
Execution evidence
These runs used real interpreters installed with
uv python install 3.9 3.10 3.11. Each run put apython3shim at the front ofPATH.Before (on
main, withpython3= 3.9.24):python3 scripts/affected-tests --helpprinted its usage and exited 0, so the selector would go on to select and run checks.python3 tests/bug_origins/regressions.pyprinted:python3 scripts/generate-release.py --checkfailed with the sameModuleNotFoundError.After (same shim, 3.9 then 3.10):
With 3.11.14, the selector went on to its normal selection and started the full Rust suite.
Before: the regression tests were written before the fix, and they failed as follows:
python3 -m unittest scripts/test_python_minimum.pyfailed 4 subtests. regressions.py printed aTraceback ...and generate-release.py printedusage: ..., where the tests expected the one-line message.test_affected_tests.AffectedTests.test_python_older_than_3_11_is_rejected_before_any_checkfailed for 3.9.18 and 3.10.14 withAssertionError: 0 == 0: the selector exited 0 and ran checks.After:
python3 -m unittest discover -s scripts -p 'test_*.py'→Ran 53 tests ... OKwith 3.12.3. Under the real 3.11.14 it also reportsOK.Full Rust suite:
scripts/affected-tests mainran on a09cfc7, andcargo test --no-fail-faston cc97102 (host Python 3.12.3).settlement::historical_review_and_reclosed_origin_regressions ... ok.affected-tests:processfindings::closing_rechecks_each_merged_base_and_leaves_a_failing_finding_for_the_day_shiftandfindings::fixing_dispatches_each_reproduced_finding_and_keeps_unreproduced_findings_private.--no-fail-fast:processfindings::merged_fix_is_rechecked_after_a_later_fix_fails(3/3 alone) andupdateconsole::admin_update_answers_after_installation_then_console_serves_the_new_version(3/3 alone).findings::closing_rechecks_...also fails intermittently onmain(1 of 3 runs), so it predates this change.Confirmed cause:
tomllibimporters checked the interpreter version.docs/testing.mdasked only for "Python 3".Merge Danger
Door: two-way
Blast Radius: tooling
The change affects only hosts whose
python3is older than 3.11. On those hosts the selector, the release generator and the settlement regression test now stop at once with one line, where before they failed later. CI's ubuntu-24.04 runners have Python 3.12. Rust code is unchanged.Review
Both reviewers read all six changed files. Reports: Standards 6 findings, Spec 2. I fixed these:
Unaddressed findings
Standards
import tomllibin scripts that live inscripts/andtests/bug_origins/. The reviewer agreed.scripts/test_python_minimum.pyandtest_affected_tests.pypin the exact message in each copy.src/evals/experiment/execution/tests.rs:188mentions macOS runners' older Python. Declined. It is outside this diff, and the fake script there avoidstomllibon purpose, which stays correct.test_python_minimum.py. No change needed. The reviewer said this is not a violation:docs/testing.mdsays to runpython3 -m unittest discover -s scripts -p 'test_*.py'for Python tooling changes, and CI runs it.Spec
docs/testing.md:122still says the Console session-expiry test "needs Python 3". Declined.tests/console/session-expiry.pyruns directly, not through the selector, and does not usetomllib, so "3.11" there would overstate what it needs. The opening paragraph states the single 3.11 minimum for the tests and the release generator.No changed file was left unread by the review.
Built with claude 2.1.314 · opus · default effort
Security review outcome
No unaddressed introduced findings.