Repository navigation
Restore free-threaded C API import test with atomic module insertion - #9498
youknowone merged 1 commit into
Conversation
Use exact-dict conditional module insertion and non-module replacement, preserving dict-subclass mapping callbacks. Restore the canonical Python 3.15 test through an explicit generic new-file updater adaptation with source hash and protected AST checks. Assisted-by: OpenAI Codex:model version unavailable
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [ ] test: cpython/Lib/test/test_free_threading (TODO: 1) dependencies: dependent tests: (no tests depend on free_threading) Legend:
|
Merging this PR will not alter performance
Comparing Footnotes
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8c482764ae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
|
|
||
| # TODO: RUSTPYTHON; executable C API exports are optional. | ||
| _PyImport_AddModuleRef = get_attribute(ctypes.pythonapi, "PyImport_AddModuleRef") |
There was a problem hiding this comment.
Keep the canonical test's missing-export failure visible
When the executable does not export PyImport_AddModuleRef, get_attribute() converts the lookup's AttributeError into SkipTest during module import, bypassing the entire concurrency test. This is a test-logic change rather than an expected-failure/TODO marker edit permitted by AGENTS.md, and it can conceal an accidental export regression in a C-API-enabled build. Preserve the canonical binding and address optional export availability in the Rust/build configuration or test-selection setup instead.
AGENTS.md reference: AGENTS.md:L277-L282
Useful? React with 👍 / 👎.
| @@ -0,0 +1,48 @@ | |||
| import ctypes | |||
There was a problem hiding this comment.
Account for builds without ctypes before loading this module
On musl builds, this unconditional import raises ModuleNotFoundError before either the symbol probe or the threading decorator can run: Lib/ctypes/__init__.py imports _ctypes, but the VM explicitly excludes its registration on musl in crates/vm/src/stdlib/mod.rs:119-129. The free-threading package remains discoverable because RustPython advertises Py_GIL_DISABLED = 1, so restoring this file adds a test-collection error on that supported target. Dependency availability needs to be accounted for before loading this module, not only when looking up the C API symbol.
Useful? React with 👍 / 👎.
Summary
test_free_threading.test_capithroughscripts/update_lib, retaining its canonical class/method/assertions and 10 × 4 concurrent-call loop.PyImport_AddModuleRefuse an atomic exact-dict VM helper: return the insertion winner, conditionally replace non-modules by identity, and re-probe after a lost race. Module creation and reference destruction stay outside dict payload locks. Dict subclasses keep their callback dispatch; non-dictsys.modulessupport is unchanged.migrate --new-file-adaptationspath for introducing reviewed import/binding adapters into a previously absent canonical file. Exact source SHA, normalized target, unique non-overlapping source blocks, protected AST, and exclusive destination creation are required. Ordinary migration defaults remain unchanged.The sole capability adapter uses existing
support.get_attributefor an absent executable C API export. It does not skip supported-but-broken implementations or alter the test body. This does not duplicate #9270's CI/Windows-export changes.Validation
-D warnings) passed, with actual VM opt-level 3 invocations.FUNC GLOBAL DEFAULT PyImport_AddModuleRef; independently bound static loader closure excludes shared libpython.Limits
One bounded canonical concurrency test is not proof of all interleavings or complete CPython C API compatibility. Non-module/subclass/generic-mapping runtime corner cases were not exercised. Generic mappings remain unsupported. Exportless builds report a capability skip, not native validation; Windows export completeness is separate (#9270).
Validated locally on Linux against main
713e14cfc78d06372c68a1804240de52a8340548. Full workspace/crate-local CAPI suites and macOS/Windows execution were not run; the native behavioral check was intentionally restricted to the unchanged canonical method.AI assistance
OpenAI Codex assisted with source investigation, implementation, updater migration, test orchestration, and independent agent review. The validation above was actually executed in the Linux environment; this does not claim human manual verification or validation on untested platforms.