Title: Warn that `gc.get_objects()` can expose objects under construction · Issue #159730 · python/cpython · GitHub
Open Graph Title: Warn that `gc.get_objects()` can expose objects under construction · Issue #159730 · python/cpython
X Title: Warn that `gc.get_objects()` can expose objects under construction · Issue #159730 · python/cpython
Description: Documentation The gc.get_objects() documentation does not mention that references created via the function may be partially initialized or allow access to uniquely referenced objects that are not observable by remote threads in any other...
Open Graph Description: Documentation The gc.get_objects() documentation does not mention that references created via the function may be partially initialized or allow access to uniquely referenced objects that are not o...
X Description: Documentation The gc.get_objects() documentation does not mention that references created via the function may be partially initialized or allow access to uniquely referenced objects that are not o...
Opengraph URL: https://github.com/python/cpython/issues/159730
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Warn that `gc.get_objects()` can expose objects under construction","articleBody":"### Documentation\n\nThe [`gc.get_objects()` documentation](https://docs.python.org/3/library/gc.html#gc.get_objects) does not mention that references created via the function may be partially initialized or allow access to uniquely referenced objects that are not observable by remote threads in any other way.\n\nI'd like like to add a warning like [the existing warning](https://docs.python.org/3/library/gc.html#gc.get_referrers) in the `gc.get_referrers()` docs.\n\nFor context, this has come up several times:\n\n- #59313 investigated an incomplete tuple whose reference count was changed by a monitoring thread calling `gc.get_objects()`. The discussion [compared this hazard](https://github.com/python/cpython/issues/59313#issuecomment-1093583138) with the existing `gc.get_referrers()` warning.\n- #151722, #152235, and #153083 reported that `gc.get_objects()` could expose `frozendict`, `set`/`frozenset`, and `array.array` objects during construction in free-threaded builds.\n- #152288 uses `gc.get_objects()` to reach a set being built. Its discussion [explicitly points to](https://github.com/python/cpython/issues/152288#issuecomment-4893145537) the warning for `gc.get_referrers()`.\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-159731\n* gh-159737\n* gh-159738\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/ngoldbaum","@type":"Person","name":"ngoldbaum"},"datePublished":"2026-10-19T18:28:08Z","url":"https://github.com/python/cpython/issues/159730"}
| 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 | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c963b36a-7544-1013-4c0b-1496600b4dbb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A846:1D20B7:3C7FA31:4C8AAE0:6B023A9D |
| html-safe-nonce | 63956e2adc509be956b6a4917f5f5c5904d42bf581803140e7bad4335e0f548d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODQ2OjFEMjBCNzozQzdGQTMxOjRDOEFBRTA6NkIwMjNBOUQiLCJ2aXNpdG9yX2lkIjoiODcxNjY0NDE2OTIwNjA4NjMwMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2afa5cae61a344bcbd9fb5553060d5f7634718093e9fb6ed543cb9e17dac09da |
| hovercard-subject-tag | issue:5929297832 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/python/cpython/159730/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ac6470833934b084e42aa7249f372d616685fe96fb8bbaf1cfb507a37e49e9e9/python/cpython/issues/159730 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ac6470833934b084e42aa7249f372d616685fe96fb8bbaf1cfb507a37e49e9e9/python/cpython/issues/159730 |
| og:image:alt | Documentation The gc.get_objects() documentation does not mention that references created via the function may be partially initialized or allow access to uniquely referenced objects that are not o... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ngoldbaum |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width