Repository navigation
Ship compiled pytest tests for Python 3.14 and 3.15; pick by interpreter - #419
Merged
Merged
Conversation
The seven checks that run students' pytest files against compiled implementations (tests/bank, tests/fuel, tests/plates, tests/twttr, numb3rs, um, working) shipped one .pyc per implementation, compiled for Python 3.14. Bytecode is specific to a minor version and the checks exec it after skipping the header, so a mismatch crashes the interpreter: 3.14 bytecode under 3.15 segfaults, 3.15 under 3.14 aborts. That tied the checks to the grader's exact Python and made moving either one an all-at-once event. Each implementation now ships as <name>.cpython-314.pyc and <name>.cpython-315.pyc (from cs50/cs50p-pytest-tests), and a small include_pyc helper in each check includes the one matching sys.version_info under the plain <name>.pyc the rest of the check expects. The checks therefore work unchanged whether the grader runs 3.14 or 3.15. tests/plates also drops an unused `from distutils.filelist import findall`; distutils was removed in Python 3.12 and the import only worked through setuptools' shim. Verified with check50 4.0.0-dev (as cs50/check ships) against the CS50P reference solutions on both Pythons: results are identical to each other and to the unmodified checks on 3.14.
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
The seven checks that run students' pytest files against compiled implementations (
tests/bank,tests/fuel,tests/plates,tests/twttr,numb3rs,um,working) now work whether the grader runs Python 3.14 or 3.15. Each implementation ships as<name>.cpython-314.pycand<name>.cpython-315.pyc(from cs50/cs50p-pytest-tests#8), and a smallinclude_pychelper in each check includes the one matchingsys.version_infounder the plain<name>.pycthe rest of the check already expects. Nothing else in the checks changes, and the student-facing side is untouched.Why not just recompile
The checks exec the bytecode after skipping the
.pycheader, and bytecode is specific to a Python minor version. A mismatch does not fail gracefully: 3.14 bytecode under 3.15 segfaults the interpreter; 3.15 under 3.14 aborts with a fatal error. A straight swap would therefore have to land in the same instant as cs50/check's Python moves, and moving cs50/check back (which a production trial should be able to do) would require reverting here too. Carrying both builds removes that coupling.Also removes an unused
from distutils.filelist import findallfromtests/plates;distutilswas removed in Python 3.12 and the import only worked through setuptools' shim.Verification
Ran all seven checks with check50 4.0.0-dev (the version cs50/check ships) against the CS50P reference solutions, three ways: these checks on Python 3.14.10, these checks on Python 3.15.2, and the unmodified
2022/pythonchecks on 3.14.10. All three produce identical results, check for check (bank 5/5, plates 7/7, twttr 8/8; fuel 8/9, numb3rs 14/15, um 10/11, working 17/19). The few non-passing checks are the same in all three and reflect the reference solutions lagging checks that were tightened later, not Python or this change. Every check that loads a compiled file passes on both versions.