fix: import Traversable from importlib.resources.abc on Python >=3.14#1540
Open
mvanhorn wants to merge 1 commit into
Open
fix: import Traversable from importlib.resources.abc on Python >=3.14#1540mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
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
Makes the
Traversableimport tolerant of Python 3.14, whereprime evalcurrently crashes on import because the symbol moved namespaces.Why
On Python 3.14+,
from importlib.abc import TraversableraisesImportErrorbecauseTraversablemoved toimportlib.resources.abc. Issue #1521 reports thatprime evaltherefore crashes at import time on a fresh 3.14 install, before any command runs, so the package is unusable on the latest Python.Description
Fixes #1521. On Python 3.14+,
from importlib.abc import TraversableraisesImportErrorbecauseTraversablemoved toimportlib.resources.abc, soprime evalcrashes on import with a fresh 3.14 install. The import is replaced with a version-tolerant guard (tryimportlib.resources.abc, fall back toimportlib.abcon Python < 3.14) across the eight affected modules inverifiers/v1/andverifiers/envs/experimental/composable/. Therequires-pythonpin is left unchanged; this PR is scoped to the import.Type of Change
Testing
uv run pytestlocally.tests/test_environment.pygainstest_importlib_traversable_modules_import, which imports all eight touched modules so a regression on either Python branch fails fast. The fallback branch keeps behavior byte-identical on 3.10 through 3.13.Checklist
Additional Notes
Traversableresolves to the same runtime type on both branches, so downstreamisinstancechecks and type hints are unaffected.Note
Low Risk
Narrow import-shim change with fallback preserving prior behavior on supported Python versions; risk is low aside from missing a
Traversableimport site.Overview
Fixes import-time crashes on Python 3.14+ where
Traversableno longer lives inimportlib.abc(it moved toimportlib.resources.abc), which broke commands likeprime evalbefore any user code ran.Each affected module now tries
importlib.resources.abcfirst and falls back toimportlib.abcon older Python, with no intended behavior change on 3.10–3.13. Updates span v1 runtime/taskset/sandbox and taskset utils plus experimental composable env, harness, task, and RLM harness.Adds
test_importlib_traversable_modules_importintests/test_environment.pyto import all eight touched modules so either import branch regressions fail fast in CI.Reviewed by Cursor Bugbot for commit 2ece238. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
Traversableimport to useimportlib.resources.abcon Python >=3.14In Python 3.14,
Traversablewas removed fromimportlib.abcand moved toimportlib.resources.abc. Eight modules acrossverifiers/are updated to use atry/exceptthat imports fromimportlib.resources.abcfirst, falling back toimportlib.abcfor older Python versions. A new test intests/test_environment.pyverifies all affected modules import successfully.Macroscope summarized 2ece238.