René's URL Explorer Experiment


Title: Add _DuringGC functions for tp_traverse · Issue #145921 · python/cpython · GitHub

Open Graph Title: Add _DuringGC functions for tp_traverse · Issue #145921 · python/cpython

X Title: Add _DuringGC functions for tp_traverse · Issue #145921 · python/cpython

Description: Feature or enhancement As seen in https://discuss.python.org/t/adding-c-api-for-use-in-tp-traverse/105331/13 and capi-workgroup/decisions#95: There are newly documented restrictions on tp_traverse: The traversal function must not have an...

Open Graph Description: Feature or enhancement As seen in https://discuss.python.org/t/adding-c-api-for-use-in-tp-traverse/105331/13 and capi-workgroup/decisions#95: There are newly documented restrictions on tp_traverse:...

X Description: Feature or enhancement As seen in https://discuss.python.org/t/adding-c-api-for-use-in-tp-traverse/105331/13 and capi-workgroup/decisions#95: There are newly documented restrictions on tp_traverse:...

Opengraph URL: https://github.com/python/cpython/issues/145921

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.112.4


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add _DuringGC functions for tp_traverse","articleBody":"# Feature or enhancement\n\nAs seen in https://discuss.python.org/t/adding-c-api-for-use-in-tp-traverse/105331/13 and https://github.com/capi-workgroup/decisions/issues/95:\n\n\nThere are [newly documented restrictions on tp_traverse](https://github.com/python/cpython/pull/142272):\n\n> The traversal function must not have any side effects. It must not modify the reference counts of any Python objects nor create or destroy any Python objects.\n\nBut, whether a C-API function modifies some reference count is an *implementation detail* that we can change at any time. Core devs can add logging, an audit event, or a warning, to virtually *any* function.\nThis implies that you can't safely use any C API function in `tp_traverse`, unless it *guarantees* that it has no side effects.\n\nI propose to add such side-effect-free versions of some functions useful in `tp_traverse`, with a `_DuringGC` suffix -- namely:\n\n- `PyObject_GetTypeData_DuringGC`\n- `PyObject_GetItemData_DuringGC`\n- `PyType_GetModuleState_DuringGC`\n- `PyModule_GetState_DuringGC`\n- `PyModule_GetToken_DuringGC`\n- `PyType_GetBaseByToken_DuringGC`\n- `PyType_GetModule_DuringGC`\n- `PyType_GetModuleByToken_DuringGC`\n\n\nCompared to their non-suffixed variants, the main difference is that we *promise* that these will remain safe to use in `tp_traverse`. The other differences are that these functions cannot fail, and (where applicable) they return borrowed references rather than strong ones.\n\nAlso, `Py_VISIT`, `Py_SIZE`, `PyObject_VisitManagedDict` as well as the `visitproc` that Python passes to `tp_traverse` will be documented to work like this.\n[edit] I'll also include a few ones useful in these: `PyObject_TypeCheck`, `PyType_IsSubtype`, `PyType_HasFeature`, `Py{\u003ctype>}_Check`, `Py{\u003ctype>}_CheckExact`.\n\nUsers that call any `_DuringGC` function (including some type's `tp_traverse`) must manually must ensure that the type, MRO, and layout of any argument doesn't concurrently change. That means only calling them from `tp_traverse`.\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-145925\n* gh-160455\n* gh-160826\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/encukou","@type":"Person","name":"encukou"},"datePublished":"2026-03-13T15:17:19Z","url":"https://github.com/python/cpython/issues/145921"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:238a91eb-5bdb-2bc1-0e76-d3216ff5326f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE9A4:2D14E:CF374B:11B2196:6B065048
html-safe-nonce2324884af33364e68441222155e2e9c0a006942df6fd60f622272235ec2b54f2
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOUE0OjJEMTRFOkNGMzc0QjoxMUIyMTk2OjZCMDY1MDQ4IiwidmlzaXRvcl9pZCI6IjQ5MzM5ODkxNjk3NzgwNzQzMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac1b6a8ca12b8637c0d2b19aba13f74ad54699ee9b764bad079176b2b617db2494
hovercard-subject-tagissue:4071745106
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/145921/issue_layout
twitter:imagehttps://opengraph.githubassets.com/dbff1dc92ed1e4c2be6a118f231af054c801a5f998c5c4b24e5ef1ca30dc8218/python/cpython/issues/145921
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/dbff1dc92ed1e4c2be6a118f231af054c801a5f998c5c4b24e5ef1ca30dc8218/python/cpython/issues/145921
og:image:altFeature or enhancement As seen in https://discuss.python.org/t/adding-c-api-for-use-in-tp-traverse/105331/13 and capi-workgroup/decisions#95: There are newly documented restrictions on tp_traverse:...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameencukou
hostnamegithub.com
expected-hostnamegithub.com
None772b6997ca4daa0428dd49a25d76052e765555ae560fe9c88517eb828bbd861e
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef1f9a08f7c769a37f1dfc18ad43d463c222a7eea
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/145921#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F145921
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F145921
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/145921
Reloadhttps://github.com/python/cpython/issues/145921
Reloadhttps://github.com/python/cpython/issues/145921
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/145921
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/145921
Add _DuringGC functions for tp_traversehttps://github.com/python/cpython/issues/145921#top
interpreter-corehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-C-APIhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-C-API%22
type-featurehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com/encukou
encukouhttps://github.com/encukou
on Mar 13, 2026https://github.com/python/cpython/issues/145921#issue-4071745106
https://discuss.python.org/t/adding-c-api-for-use-in-tp-traverse/105331/13https://discuss.python.org/t/adding-c-api-for-use-in-tp-traverse/105331/13
capi-workgroup/decisions#95https://github.com/capi-workgroup/decisions/issues/95
newly documented restrictions on tp_traversehttps://github.com/python/cpython/pull/142272
gh-145921: Add "_DuringGC" functions for tp_traverse #145925https://github.com/python/cpython/pull/145925
gh-145921: Clarify return value of tp_traverse #160455https://github.com/python/cpython/pull/160455
[3.15] gh-145921: Clarify return value of tp_traverse (GH-160455) #160826https://github.com/python/cpython/pull/160826
encukouhttps://github.com/encukou
type-featurehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
topic-C-APIhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-C-API%22
on Mar 13, 2026https://github.com/python/cpython/issues/145921#event-23550253188
encukouhttps://github.com/encukou
on Mar 13, 2026https://github.com/python/cpython/issues/145921#event-23550645996
encukouhttps://github.com/encukou
on Mar 13, 2026https://github.com/python/cpython/issues/145921#event-23551315485
pythongh-145921: Add "_DuringGC" functions for tp_traversehttps://github.com/encukou/cpython/commit/797312f786dcfd2798cb3addfce05e3ea24b55e7
pythongh-145921https://github.com/python/cpython/issues/145921
797312fhttps://github.com/encukou/cpython/commit/797312f786dcfd2798cb3addfce05e3ea24b55e7
StanFromIrelandhttps://github.com/StanFromIreland
interpreter-corehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
on Mar 13, 2026https://github.com/python/cpython/issues/145921#event-23551960923
pythonhttps://github.com/python
khalidsaidihttps://github.com/khalidsaidi
on Mar 14, 2026https://github.com/python/cpython/issues/145921#event-23574804717
https://github.com/encukou
encukouhttps://github.com/encukou
on Apr 8, 2026https://github.com/python/cpython/issues/145921#issuecomment-4204475848
encukouhttps://github.com/encukou
on Apr 8, 2026https://github.com/python/cpython/issues/145921#event-24285605820
gh-145921: Add "_DuringGC" functions for tp_traverse (GH-145925)https://github.com/python/cpython/commit/8923ca418cef1d07cd79ab810d12a24f7817dd89
gh-145921https://github.com/python/cpython/issues/145921
GH-145925https://github.com/python/cpython/pull/145925
8923ca4https://github.com/python/cpython/commit/8923ca418cef1d07cd79ab810d12a24f7817dd89
encukouhttps://github.com/encukou
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Apr 15, 2026https://github.com/python/cpython/issues/145921#event-24523199780
encukouhttps://github.com/encukou
on Apr 15, 2026https://github.com/python/cpython/issues/145921#event-24523202539
ljfphttps://github.com/ljfp
on Apr 25, 2026https://github.com/python/cpython/issues/145921#event-24868337329
pythongh-145921: Add "_DuringGC" functions for tp_traverse (pythonGH-…https://github.com/ljfp/cpython/commit/8061518bf02fa0544b52b569253beb1aa800090c
pythongh-145921https://github.com/python/cpython/issues/145921
pythonGH-…https://github.com/python/cpython/pull/145925
8061518https://github.com/ljfp/cpython/commit/8061518bf02fa0544b52b569253beb1aa800090c
https://github.com/encukou
encukouhttps://github.com/encukou
on Oct 22, 2026https://github.com/python/cpython/issues/145921#issuecomment-6353677655
@naschemehttps://github.com/nascheme
https://github.com/nascheme
naschemehttps://github.com/nascheme
on Oct 23, 2026https://github.com/python/cpython/issues/145921#issuecomment-6369725924
encukouhttps://github.com/encukou
on Oct 23, 2026https://github.com/python/cpython/issues/145921#event-34077355221
pythongh-145921: Clarify return value of tp_traversehttps://github.com/encukou/cpython/commit/03d41f6a19f95b18a8989553f0fbbc4989747e99
pythongh-145921https://github.com/python/cpython/issues/145921
03d41f6https://github.com/encukou/cpython/commit/03d41f6a19f95b18a8989553f0fbbc4989747e99
gh-145921: Clarify return value of tp_traverse (GH-160455)https://github.com/python/cpython/commit/cfe7e0a5ea5043991492ee71a8c6a322172b353a
gh-145921https://github.com/python/cpython/issues/145921
GH-160455https://github.com/python/cpython/pull/160455
cfe7e0ahttps://github.com/python/cpython/commit/cfe7e0a5ea5043991492ee71a8c6a322172b353a
[3.15] gh-145921: Clarify return value of tp_traverse (GH-160455) (GH…https://github.com/python/cpython/commit/a6616f25d95a497ed05e3bb23ae7aa982c2845ce
gh-145921https://github.com/python/cpython/issues/145921
GH-160455https://github.com/python/cpython/pull/160455
GH…https://github.com/python/cpython/pull/160826
a6616f2https://github.com/python/cpython/commit/a6616f25d95a497ed05e3bb23ae7aa982c2845ce
https://github.com/encukou
encukouhttps://github.com/encukou
on Oct 28, 2026https://github.com/python/cpython/issues/145921#issuecomment-6476196607
@naschemehttps://github.com/nascheme
some functions like thishttps://docs.python.org/3/c-api/gcsupport.html#traversal-safe-functions
encukouhttps://github.com/encukou
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Oct 28, 2026https://github.com/python/cpython/issues/145921#event-34502952886
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/145921
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/145921
interpreter-corehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-C-APIhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-C-API%22
type-featurehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.