GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Restore free-threaded C API import test with atomic module insertion by youknowdot · Pull Request #9498 · RustPython/RustPython

Conversation

@youknowdot

@youknowdot youknowdot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Restore CPython 3.15 test_free_threading.test_capi through scripts/update_lib, retaining its canonical class/method/assertions and 10 × 4 concurrent-call loop.
  • Make PyImport_AddModuleRef use 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-dict sys.modules support is unchanged.
  • Add an explicit, generic migrate --new-file-adaptations path 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_attribute for 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

  • Host updater suite: 233 tests passed, including metadata/path/hash/block/AST/symlink/overwrite rejection coverage.
  • Ruff formatting/check and diff whitespace checks passed.
  • Linux CAPI-enabled locked/offline Cargo check and strict Clippy (-D warnings) passed, with actual VM opt-level 3 invocations.
  • Linux CAPI-enabled CLI build passed. ELF export is defined FUNC GLOBAL DEFAULT PyImport_AddModuleRef; independently bound static loader closure excludes shared libpython.
  • Canonical test: pinned CPython d220409a free-threaded reference and corrected RustPython each ran exactly one test with zero skips/failures/errors. Original 10 × 4 body was unchanged. FT GIL state stayed disabled before/after ctypes/support imports and the test, without forcing a GIL override. Owned process/thread cleanup and source/artifact snapshots were checked.
  • Actual updater generation replay matched bytes; canonical class/function AST matched pinned CPython.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@codex
Restore free-threaded C API import test with atomic module insertion
8c48276
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
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share
  • X
  • Mastodon
  • Reddit
  • LinkedIn
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

📦 Library Dependencies

The 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:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codspeed

codspeed Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing youknowdot:upgrade/atomic-add-module-ref-20261031 (8c48276) with main (713e14c)

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@youknowdot youknowdot mentioned this pull request Oct 31, 2026
Restore canonical limited C API consumer tests #9501
Merged
youknowone
youknowone approved these changes Oct 31, 2026
View reviewed changes
@youknowone
youknowone marked this pull request as ready for review October 31, 2026 23:17
@youknowone
youknowone merged commit 69ee493 into RustPython:main Oct 31, 2026
30 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T23:26:19.617786Z 8c48276 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chatgpt-codex-connector[bot]
chatgpt-codex-connector Bot reviewed Oct 31, 2026
View reviewed changes

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_free_threading/test_capi.py


# TODO: RUSTPYTHON; executable C API exports are optional.
_PyImport_AddModuleRef = get_attribute(ctypes.pythonapi, "PyImport_AddModuleRef")

@chatgpt-codex-connector chatgpt-codex-connector Bot Oct 31, 2026

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_free_threading/test_capi.py
@@ -0,0 +1,48 @@
import ctypes

@chatgpt-codex-connector chatgpt-codex-connector Bot Oct 31, 2026

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@youknowdot youknowdot mentioned this pull request Oct 31, 2026
Restore ten guarded C API test modules #9505
Draft
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@chatgpt-codex-connector chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] left review comments
@youknowone youknowone youknowone approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@youknowdot @youknowone @codex
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.