Title: Align GC controls, introspection and explicit collection callbacks by youknowdot · Pull Request #9842 · RustPython/RustPython · GitHub
Open Graph Title: Align GC controls, introspection and explicit collection callbacks by youknowdot · Pull Request #9842 · RustPython/RustPython
X Title: Align GC controls, introspection and explicit collection callbacks by youknowdot · Pull Request #9842 · RustPython/RustPython
Description: Summary Fix adjacent GC control, introspection and explicit-collection callback mismatches as one batch: Emit all three introspection audit events with the correct argument shape and exception precedence. Retain and exclude the audited argument tuple from get_referrers; without hooks, do not allocate or clone that tuple. Match get_objects optional index-sized generation conversion, including None/-1, bounds, original-type diagnostics and UTF-8 byte limits. Exclude frozen permanent-generation objects from public object/referrer snapshots while preserving the inclusive internal snapshots used by shutdown and ownership code. Preserve signed and unknown debug bits. Store signed C-int thresholds, preserve omitted thresholds and atomicity on conversion failure, and match the optional-group wrapper's arity/error ordering. Reuse ArgCInt for collect/set_debug; retain the distinct legacy i conversion required by set_threshold. Match the nonzero/strictly-greater threshold trigger rather than treating negative thresholds as disabled. Hold the existing collector exclusion through explicit collection's start/stop callbacks. Recursive collection returns zero without recursively notifying callbacks. Read the callback list live so append/remove/clear behavior matches CPython, and report callback errors through sys.unraisablehook without 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 ArgIndex deliberately 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_gc and place all additional Python regressions in the existing stdlib_gc.py, including audit denial, retained tuples, frozen objects, configuration boundaries, failed-conversion state preservation, recursive callbacks, list mutation and unraisable reporting. Final -m test test_gc test_audit: 94 run, 22 skipped, success. Entire expanded stdlib_gc.py: passes RustPython and actual CPython 3.15.0/3.15.2. cargo build --features sqlite and cargo clippy --features sqlite -- -D warnings: passed. All 9 gc_state::tests passed, including strict-threshold boundary and busy-collector/owner checks. Full VM unit suite: 235 passed, 2 ignored. Negative-threshold automatic collection separately exercised successfully on CPython and RustPython. Normal pre-commit hooks and independent source reviews passed. 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.
Open Graph Description: Summary Fix adjacent GC control, introspection and explicit-collection callback mismatches as one batch: Emit all three introspection audit events with the correct argument shape and exception pre...
X Description: Summary Fix adjacent GC control, introspection and explicit-collection callback mismatches as one batch: Emit all three introspection audit events with the correct argument shape and exception pre...
Opengraph URL: https://github.com/RustPython/RustPython/pull/9842
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:d475e29e-f1e1-fc4d-928a-837b85ec8f51 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8E18:CC1A4:34F3FE0:4361087:6B01DEAD |
| html-safe-nonce | 196fdb2407e552e24d5cbfc5a6436cf4be7ea74fb34344d642fa97ed5f716738 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTE4OkNDMUE0OjM0RjNGRTA6NDM2MTA4Nzo2QjAxREVBRCIsInZpc2l0b3JfaWQiOiIyMDgzMjcxNDM2MjkzNzU4NjM4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 0e71bb834a01c1432c44a18645dd79a08a62dd3ad8ad749546ca8dba9ead0242 |
| hovercard-subject-tag | pull_request:5314293229 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/9842/files |
| twitter:image | https://avatars.githubusercontent.com/u/336763669?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/336763669?s=400&v=4 |
| og:image:alt | Summary Fix adjacent GC control, introspection and explicit-collection callback mismatches as one batch: Emit all three introspection audit events with the correct argument shape and exception pre... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width