Repository navigation
Align native threading and libraries with Python 3.15 - #9148
Conversation
Preserve lock ownership and elapsed timeouts during interruptible waits; reject RLock constructor arguments and use replacement encoding for thread names. Generate associated libraries and tests from CPython d220409a13b77de7a6c30abe16ea90db01528edc using update_lib, retaining five existing markers and retiring one proven removed test owner. AI-assisted source preparation and review. Runtime validation remains pending. Assisted-by: OpenAI Codex:model version unavailable
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
⛔ Files ignored due to path filters: 5
📒 Files selected for processing: 1
✨ Finishing Touches
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. Comment |
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: :4: SyntaxWarning: invalid decimal literal dependencies:
dependent tests: (17 tests)
[x] lib: cpython/Lib/threading.py dependencies:
dependent tests: (168 tests)
[ ] lib: cpython/Lib/asyncio dependencies:
dependent tests: (8 tests)
[x] test: cpython/Lib/test/test_thread.py (TODO: 1) dependencies: dependent tests: (14 tests) Legend:
|
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: 54142418ba
ℹ️ 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".
| # PyThreadState_SetAsyncExc() is a CPython-only gimmick, not (currently) | ||
| # exposed at the Python level. This test relies on ctypes to get at it. | ||
| @unittest.expectedFailure # TODO: RUSTPYTHON | ||
| @cpython_only |
There was a problem hiding this comment.
Keep the RustPython async-exception test runnable
On every RustPython run, @cpython_only turns this already-marked expected failure into a skip, so the body is no longer exercised and eventual support for PyThreadState_SetAsyncExc cannot surface as an unexpected success. This body previously ran under expectedFailure and is not a crash or hang case, so keep the RustPython expected-failure marker without this skip.
AGENTS.md reference: AGENTS.md:L98-L101
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
You’re right that this body is skipped on RustPython. The @cpython_only guard comes directly from exact CPython 3.15 final, and update_lib preserved the existing RustPython expectedFailure above it. This sync keeps upstream implementation guards intact, so I’m leaving the canonical decorator in place. This conclusion is source-only; I’m not claiming that the PyThreadState_SetAsyncExc test ran.
Summary
Split the native threading work and its associated Python libraries from the larger Python 3.15 update, keeping them together in one six-file change.
RLockwhen the class retains its base initializer, while preserving subclasses with a custom initializer.RLockduring an already-pending outer acquisition, keep that outer acquisition contended without recursively acquiring the raw lock or overwriting the handler's ownership/count.threading,_threading_local, and the three related canonical test files from CPythond220409a13b77de7a6c30abe16ea90db01528edc, including the associated iterator utilities.No C-API exports, foreign-thread cleanup, thread-handle/lifetime redesign, updater changes, or duplicate snippets are included.
Canonical Python provenance
All five Python files were generated through the actual
scripts/update_libCLI against that exact CPython source:copy-libforthreading.py, including its existing_threading_local.pydependencymigratefortest_threading.py,lock_tests.py, andtest_thread_local_bytecode.pypatchesmetadata route for the finaltest_threading.pyoutputFour files are byte-identical to the pinned upstream source.
test_threading.pydiffers only by five existing RustPython markers: four expected failures and one skip. The sixth original marker belonged to the obsoleteThreadTests.test_tstate_lockwrapper; its owner is absent from the pinned upstream class and its fullTestCaseancestry, so only that metadata entry was removed before regenerating. No canonical assertions or test bodies were hand-edited, and no marker was removed based on an unrun test result.Validation
At commit
54142418ba8fbbc8970e105c3d1e3cd8135e190f:--no-default-features --features threading,stdlib,stdio,importlib,host_env.cargo clippy --release --offline --locked -p rustpython-vm --all-targets --no-default-features --features compiler,gc,host_env,stdio,importlib,encodings,threading -- -D warnings.Selected tests under
test.test_threading:ThreadTests.test_lock_no_argsLockTests.test_constructor,LockTests.test_constructor_noargsPyRLockTests.test_constructor,PyRLockTests.test_constructor_noargsCRLockTests.test_constructor,CRLockTests.test_constructor_noargs,CRLockTests.test_signatureThreadingIteratorToolsTests.test_serialize_generator_methodsThreadingIteratorToolsTests.test_serialize_methods_attribute_errorThreadingIteratorToolsTests.test_serialize_generator_methods_lockingThreadingIteratorToolsTests.test_serialize_next_exceptionThreadingIteratorToolsTests.test_synchronized_preserves_wrapped_metadataThreadingIteratorToolsTests.test_concurrent_tee_zero_iteratorsThreadingIteratorToolsTests.test_concurrent_tee_negative_nLimits and review notes
This remains a draft. The selected tests do not validate contended waits, finalization, or signal-handler reentrancy. Full workspace/C-API tests and broad threading, daemon, fork, signals, GC, shutdown,
SetAsyncExc, and resource-limit suites were not run.The 50 ms polling approach approximates OS signal interruption: a signal arriving during the terminal wait slice may be observed only after timeout or successful acquisition. This does not claim exact CPython interruption event ordering. Existing lifetime/handle behavior and
_acquire_restorebehavior are unchanged.AI assistance was used for source preparation, review, and bounded validation. The commit carries the required
Assisted-bytrailer.