Skip to content

fix: import Traversable from importlib.resources.abc on Python >=3.14#1540

Open
mvanhorn wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
mvanhorn:fix/1521-importlib-traversable-py314
Open

fix: import Traversable from importlib.resources.abc on Python >=3.14#1540
mvanhorn wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
mvanhorn:fix/1521-importlib-traversable-py314

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Jun 4, 2026

Copy link
Copy Markdown

Summary

Makes the Traversable import tolerant of Python 3.14, where prime eval currently crashes on import because the symbol moved namespaces.

Why

On Python 3.14+, from importlib.abc import Traversable raises ImportError because Traversable moved to importlib.resources.abc. Issue #1521 reports that prime eval therefore 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 Traversable raises ImportError because Traversable moved to importlib.resources.abc, so prime eval crashes on import with a fresh 3.14 install. The import is replaced with a version-tolerant guard (try importlib.resources.abc, fall back to importlib.abc on Python < 3.14) across the eight affected modules in verifiers/v1/ and verifiers/envs/experimental/composable/. The requires-python pin is left unchanged; this PR is scoped to the import.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Test improvement

Testing

  • All existing tests pass when running uv run pytest locally.
  • New tests have been added to cover the changes

tests/test_environment.py gains test_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

  • My code follows the style guidelines of this project as outlined in AGENTS.md
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Additional Notes

Traversable resolves to the same runtime type on both branches, so downstream isinstance checks 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 Traversable import site.

Overview
Fixes import-time crashes on Python 3.14+ where Traversable no longer lives in importlib.abc (it moved to importlib.resources.abc), which broke commands like prime eval before any user code ran.

Each affected module now tries importlib.resources.abc first and falls back to importlib.abc on 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_import in tests/test_environment.py to 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 Traversable import to use importlib.resources.abc on Python >=3.14

In Python 3.14, Traversable was removed from importlib.abc and moved to importlib.resources.abc. Eight modules across verifiers/ are updated to use a try/except that imports from importlib.resources.abc first, falling back to importlib.abc for older Python versions. A new test in tests/test_environment.py verifies all affected modules import successfully.

Macroscope summarized 2ece238.

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.

from importlib.abc import Traversable doesn't work with Python >=3.14

1 participant