Repository navigation
Align GC controls, introspection and explicit collection callbacks - #9842
Conversation
Preserve CPython signed configuration and conversion diagnostics; audit introspection and exclude frozen/argument tuple objects; guard collection callbacks and honor live-list mutation and unraisable reporting. Bundle regression coverage in stdlib_gc and restore the audit test. Assisted-by: Codex:gpt-6.1-sol
|
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: [x] test: cpython/Lib/test/test_sys.py (TODO: 4) dependencies: dependent tests: (251 tests)
Legend:
|
Codex Review Summary: ❌ FailedThis 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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary
Fix adjacent GC control, introspection and explicit-collection callback mismatches as one batch:
get_referrers; without hooks, do not allocate or clone that tuple.get_objectsoptional index-sized generation conversion, includingNone/-1, bounds, original-type diagnostics and UTF-8 byte limits.ArgCIntforcollect/set_debug; retain the distinct legacyiconversion required byset_threshold.sys.unraisablehookwithout replacing the original exception if callback repr fails.The collector body is factored without changing its tracing/clearing algorithm. Its generation locks, stop-the-world guards and temporary roots are gone before stop callbacks run; the pre-existing collector lock remains held. Automatic/internal entry points use monomorphized no-op closures, not another flag, heap allocation or dynamic callback dispatch.
Reference
CPython 3.15.2 Modules/gcmodule.c, generated argument handling, and Python/gc.c.
The local typed generation converter preserves original-object type information that
ArgIndexdeliberately discards. The legacy threshold converter executes__index__and the successful integer conversion once; its C-long range check is needed only on overflow for the legacy diagnostic.Tests
Restore
test_audit.test_gcand place all additional Python regressions in the existingstdlib_gc.py, including audit denial, retained tuples, frozen objects, configuration boundaries, failed-conversion state preservation, recursive callbacks, list mutation and unraisable reporting.-m test test_gc test_audit: 94 run, 22 skipped, success.stdlib_gc.py: passes RustPython and actual CPython 3.15.0/3.15.2.cargo build --features sqliteandcargo clippy --features sqlite -- -D warnings: passed.gc_state::testspassed, including strict-threshold boundary and busy-collector/owner checks. Full VM unit suite: 235 passed, 2 ignored.Scope and remaining differences
This is not a collector redesign or a claim of complete GC parity. Automatic-collection callback wiring remains unchanged: non-threading collection can currently occur inside allocation while internal locks are held, so invoking Python there would be unsafe. Generation-1/2 automatic scheduling, interpreter lifetime work, and generator/frame referent representation are not changed. Other audit expected failures requiring platform APIs or CPython C API/object layout remain in place.