René's URL Explorer Experiment


Title: Interned strings are immortal, despite what the documentation says · Issue #113993 · python/cpython · GitHub

Open Graph Title: Interned strings are immortal, despite what the documentation says · Issue #113993 · python/cpython

X Title: Interned strings are immortal, despite what the documentation says · Issue #113993 · python/cpython

Description: Bug report Bug description: The sys.intern documentation explicitly says: Interned strings are not immortal; you must keep a reference to the return value of intern() around to benefit from it. However, they were made immortal in #19474 ...

Open Graph Description: Bug report Bug description: The sys.intern documentation explicitly says: Interned strings are not immortal; you must keep a reference to the return value of intern() around to benefit from it. How...

X Description: Bug report Bug description: The sys.intern documentation explicitly says: Interned strings are not immortal; you must keep a reference to the return value of intern() around to benefit from it. How...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Interned strings are immortal, despite what the documentation says","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\nThe [`sys.intern` documentation](https://docs.python.org/3.13/library/sys.html#sys.intern) explicitly says:\r\n\r\n\u003e Interned strings are not [immortal](https://docs.python.org/3.13/glossary.html#term-immortal); you must keep a reference to the return value of [`intern()`](https://docs.python.org/3.13/library/sys.html#sys.intern) around to benefit from it.\r\n\r\nHowever, they were made immortal in https://github.com/python/cpython/pull/19474 (Implement Immortal Objects -- implementation of PEP 683), without a documentation update. The 3.12 What's New also doesn't mention the change. [edit: it's now clear that the PR author (@eduardo-elizondo) intended it but the reviewer (@markshannon) did not]\r\nPEP-683 itself only mentions the change as a possible optimization.\r\n\r\nMeanwhile, `pathlib` [interns every path segment it processes](https://github.com/python/cpython/blob/79970792fd2c70f77c38e08c7b3a9daf6a11bde1/Lib/pathlib/__init__.py#L257), presumably depending on the documented behaviour. In CPython's test suite, that causes names of temporary directories to leak (stealthily, since interned strings are excluded from the total refcount).\r\n[edit: Worse, `type_setattro`, `PyObject_SetAttr` or `PyDict_SetItemString` immortalize keys, so strings used for key/attribute names this way are not reclaimed until interpreter shutdown.]\r\nOn the other hand, free-threading (PEP-703) ~~seems to rely~~ [edit: relies] on these being immortal.\r\n\r\nWhat's the correct behaviour? [edit: specifically, in 3.12 and non-free-threading 3.13, should this change be reverted or documented?]\r\n\r\n@eduardo-elizondo @ericsnowcurrently\r\n\r\n\r\n\u003c!-- gh-linked-prs --\u003e\r\n### Linked PRs\r\n* gh-120520\r\n* gh-120945\r\n* gh-121358\r\n* gh-121364\r\n* gh-121851\r\n* gh-121854\r\n* gh-123065\n* gh-124938\n* gh-127250\n\u003c!-- /gh-linked-prs --\u003e\r\n\r\nRelated fixes:\r\n- https://github.com/python/cpython/pull/121903\r\n- https://github.com/python/cpython/pull/122303\r\n- https://github.com/python/cpython/pull/122421","author":{"url":"https://github.com/encukou","@type":"Person","name":"encukou"},"datePublished":"2024-01-12T16:49:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":37},"url":"https://github.com/113993/cpython/issues/113993"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:067b7dcf-15d0-6fde-3f80-d9945d2dc5f0
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9F68:21E6C4:42247B:5C6941:696A213E
html-safe-nonce9a9c5437427eb08ff61bc1b4ed1c8017ae8ca6b94251d2d4ca103452032f2a97
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjY4OjIxRTZDNDo0MjI0N0I6NUM2OTQxOjY5NkEyMTNFIiwidmlzaXRvcl9pZCI6IjcwMzM0NDM4MTAxMTIzMTU3MTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac9ea37b94ff91c2c9d3d4439d2c2b2237f742896358960d0c7b128722e2a0faca
hovercard-subject-tagissue:2079272299
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/113993/issue_layout
twitter:imagehttps://opengraph.githubassets.com/0f13f20e7322b8e7eee66231ccd0759add4e89b09a620db709772bf04bb40c17/python/cpython/issues/113993
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/0f13f20e7322b8e7eee66231ccd0759add4e89b09a620db709772bf04bb40c17/python/cpython/issues/113993
og:image:altBug report Bug description: The sys.intern documentation explicitly says: Interned strings are not immortal; you must keep a reference to the return value of intern() around to benefit from it. How...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameencukou
hostnamegithub.com
expected-hostnamegithub.com
None014f3d193f36b7d393f88ca22d06fbacd370800b40a547c1ea67291e02dc8ea3
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
released515f6f09fa57a93bf90355cb894eb84ca4f458f
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/113993#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F113993
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F113993
Sign up https://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/113993
Reloadhttps://github.com/python/cpython/issues/113993
Reloadhttps://github.com/python/cpython/issues/113993
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/113993
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/issues/113993
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/113993
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/113993
Interned strings are immortal, despite what the documentation sayshttps://github.com/python/cpython/issues/113993#top
topic-subinterpretershttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-subinterpreters%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/encukou
https://github.com/encukou
encukouhttps://github.com/encukou
on Jan 12, 2024https://github.com/python/cpython/issues/113993#issue-2079272299
sys.intern documentationhttps://docs.python.org/3.13/library/sys.html#sys.intern
immortalhttps://docs.python.org/3.13/glossary.html#term-immortal
intern()https://docs.python.org/3.13/library/sys.html#sys.intern
#19474https://github.com/python/cpython/pull/19474
@eduardo-elizondohttps://github.com/eduardo-elizondo
@markshannonhttps://github.com/markshannon
PEP-683https://peps.python.org/683
interns every path segment it processeshttps://github.com/python/cpython/blob/79970792fd2c70f77c38e08c7b3a9daf6a11bde1/Lib/pathlib/__init__.py#L257
PEP-703https://peps.python.org/703
@eduardo-elizondohttps://github.com/eduardo-elizondo
@ericsnowcurrentlyhttps://github.com/ericsnowcurrently
gh-113993: Allow interned strings to be mortal, and fix related issues #120520https://github.com/python/cpython/pull/120520
[3.13] gh-113993: Allow interned strings to be mortal, and fix related issues (GH-120520) #120945https://github.com/python/cpython/pull/120945
gh-113993: For string interning, do not rely on (or assert) _Py_IsImmortal #121358https://github.com/python/cpython/pull/121358
gh-113993: Don't immortalize in PyUnicode_InternInPlace; keep immortalizing in other API #121364https://github.com/python/cpython/pull/121364
[3.13] gh-113993: For string interning, do not rely on (or assert) _Py_IsImmortal (GH-121358) #121851https://github.com/python/cpython/pull/121851
[3.13] gh-113993: Don't immortalize in PyUnicode_InternInPlace; keep immortalizing in other API (GH-121364) #121854https://github.com/python/cpython/pull/121854
[3.12] gh-113993: Make interned strings mortal (GH-120520, GH-121364, GH-121903, GH-122303) #123065https://github.com/python/cpython/pull/123065
[3.12] gh-113993: For string interning, do not rely on (or assert) _Py_IsImmortal (GH-121358) (GH-121851) #124938https://github.com/python/cpython/pull/124938
gh-113993: InternalDocs: Add String Interning to README #127250https://github.com/python/cpython/pull/127250
gh-121863: Immortalize names in code objects to avoid crash #121903https://github.com/python/cpython/pull/121903
gh-122291: Intern latin-1 one-byte strings at startup #122303https://github.com/python/cpython/pull/122303
gh-122420: Fix accounting for immortal interned strings in refleak.py #122421https://github.com/python/cpython/pull/122421
topic-subinterpretershttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-subinterpreters%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
Subinterpretershttps://github.com/orgs/python/projects/3
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

Viewport: width=device-width


URLs of crawlers that visited me.