René's URL Explorer Experiment


Title: `test_capi.test_unicode.test_check_interned` fails on a default build that reads a `.pyc` written by a free-threaded build · Issue #162092 · python/cpython · GitHub

Open Graph Title: `test_capi.test_unicode.test_check_interned` fails on a default build that reads a `.pyc` written by a free-threaded build · Issue #162092 · python/cpython

X Title: `test_capi.test_unicode.test_check_interned` fails on a default build that reads a `.pyc` written by a free-threaded build · Issue #162092 · python/cpython

Description: Bug report I was exploring peak RSS gaps of the free-threaded build with mimalloc v3 (#159718) with overnight stress tests and had a default build and a free-threaded build configured out of tree from one checkout, as a reference. The de...

Open Graph Description: Bug report I was exploring peak RSS gaps of the free-threaded build with mimalloc v3 (#159718) with overnight stress tests and had a default build and a free-threaded build configured out of tree f...

X Description: Bug report I was exploring peak RSS gaps of the free-threaded build with mimalloc v3 (#159718) with overnight stress tests and had a default build and a free-threaded build configured out of tree f...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`test_capi.test_unicode.test_check_interned` fails on a default build that reads a `.pyc` written by a free-threaded build","articleBody":"### Bug report\n\nI was exploring peak RSS gaps of the free-threaded build with mimalloc v3 (https://github.com/python/cpython/pull/159718) with overnight stress tests and had a default build and a free-threaded build configured out of tree from one checkout, as a reference. The default build then fails one test every time, also when it runs alone:\n\n```\n$ ./python -m test test_capi -m test_check_interned\n  File \"Lib/test/test_capi/test_unicode.py\", line 1896, in test_check_interned\n    self.assertEqual(check_interned(s), SSTATE_INTERNED_MORTAL)\nAssertionError: 2 != 1\n```\n\nIt looks like an assumption of the test (added in https://github.com/python/cpython/pull/157798, also in 3.14 and 3.15) rather than a runtime bug. Main at e8c0584877 (2026-11-10) on Linux arm64, and at 7c59816cb4 (2026-11-16) on macOS arm64. An AI assistant helped with the analysis.\n\n### What happens\n\nWhether it fails depends on which build wrote `Lib/test/test_capi/__pycache__/test_unicode.cpython-316.pyc`:\n\n| the `.pyc` was written by | test run by the default build | test run by the free-threaded build |\n|---|---|---|\n| the default build | passes | passes |\n| the free-threaded build | fails | passes |\n\nBoth builds use the cache tag `cpython-316`, so they read each other's `.pyc` files. The free-threaded build interns every string constant of a code object ([`_PyCode_ShouldInternString()`](https://github.com/python/cpython/blob/e8c0584877e0/Objects/codeobject.c#L116-L137)), and marshal [writes](https://github.com/python/cpython/blob/e8c0584877e0/Python/marshal.c#L1043-L1046) an interned string as `TYPE_INTERNED`. When the default build loads such a file, marshal [interns](https://github.com/python/cpython/blob/e8c0584877e0/Python/marshal.c#L1801-L1806) every string marked that way as immortal. The test's literal `'long string unlikely to be used by Python'` is a constant of the test's own code, so it is already interned and immortal by then, and `sys.intern()` of an equal fresh string returns that one.\n\nWith `PYTHONPYCACHEPREFIX` pointing to a directory of its own, the default build passes, and so does its full test suite.\n\n### Without the test suite\n\n```python\n# interned_mod.py\nimport sys, _testcapi\n\ndef fresh_string(text):\n    return text.encode().decode()\n\ns = sys.intern(fresh_string('long string unlikely to be used by Python'))\nprint(\"free-threaded\" if \"t\" in sys.abiflags else \"default (GIL)\", \"build: PyUnicode_CHECK_INTERNED() of an interned copy is\", _testcapi.unicode_check_interned(s), \"(1 = mortal, 2 = immortal)\")\n```\n\n```\n$ rm -rf __pycache__; default/python -c \"import interned_mod\"\ndefault (GIL) build: PyUnicode_CHECK_INTERNED() of an interned copy is 1 (1 = mortal, 2 = immortal)\n$ rm -rf __pycache__; free-threaded/python -c \"import interned_mod\"\nfree-threaded build: PyUnicode_CHECK_INTERNED() of an interned copy is 2 (1 = mortal, 2 = immortal)\n$ default/python -c \"import interned_mod\"\ndefault (GIL) build: PyUnicode_CHECK_INTERNED() of an interned copy is 2 (1 = mortal, 2 = immortal)\n```\n\n### A possible change\n\nThe test could intern a text that is put together at run time, so that it can't be a constant of its own code. Other tests build such strings at run time too, to get one that isn't interned yet, for example `test_capi/test_object.py` (`''.join(['decref', '_delayed', '_immortal'])`) and `test_sys.test_intern` (`\"never interned before\" + str(random.randrange(0, 10**9))`). In `Lib/test/test_capi/test_unicode.py`:\n\n```diff\n-        s = fresh_string('long string unlikely to be used by Python')\n+        # Built at run time: a constant of this module may already be\n+        # interned (and immortal) when the .pyc file was written by a\n+        # free-threaded build.\n+        s = fresh_string(''.join(['long string ', 'unlikely to be used by Python']))\n```\n\nWith that change the test passes on the default build with a `.pyc` written by the free-threaded build, and the other way round, and `test_capi.test_unicode` passes on both builds. I'll open a PR with this change.\n\nOne thing beyond the test, in case it is of interest: a default build that loads `.pyc` files written by a free-threaded build keeps every string constant of those modules immortal. That only happens where both builds import the same source files, for example two builds from one checkout, or a project's own modules run with both `python3.16` and `python3.16t` (the installed standard libraries are separate). I haven't measured what it costs, and whether the two builds should share `.pyc` files at all is a separate question; the test change doesn't depend on it.\n\ncc @vstinner\n\n\n### CPython versions tested on:\n\n3.14, 3.15, CPython main branch\n\n### Operating systems tested on:\n\nmacOS, Linux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-162099\n* gh-162118\n* gh-162119\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/maikschulze","@type":"Person","name":"maikschulze"},"datePublished":"2026-11-16T08:30:56Z","url":"https://github.com/python/cpython/issues/162092"}

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:33f7520c-2428-5208-5cfe-64334b20f623
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id94DA:28A483:11DA929:17AB1DF:6B01E84A
html-safe-nonce7fccebaa665c484c4d75d9993580d4573fe454858761959ad10c17b0a07ad77f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NERBOjI4QTQ4MzoxMURBOTI5OjE3QUIxREY6NkIwMUU4NEEiLCJ2aXNpdG9yX2lkIjoiNjE2NDAwNzg0NTYwNjEzNDUwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacc282afa18864956025f3f7c5516bd66858cc4488659fee8b6dfd2d3aaedbf19f
hovercard-subject-tagissue:6417328431
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/162092/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f3dbc1476c2d69345db698a7128798d6cf40df2166a965006411132d8344c9e1/python/cpython/issues/162092
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f3dbc1476c2d69345db698a7128798d6cf40df2166a965006411132d8344c9e1/python/cpython/issues/162092
og:image:altBug report I was exploring peak RSS gaps of the free-threaded build with mimalloc v3 (#159718) with overnight stress tests and had a default build and a free-threaded build configured out of tree f...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemaikschulze
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/162092#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F162092
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%2F162092
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/162092
Reloadhttps://github.com/python/cpython/issues/162092
Reloadhttps://github.com/python/cpython/issues/162092
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/162092
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/162092
test_capi.test_unicode.test_check_interned fails on a default build that reads a .pyc written by a free-threaded buildhttps://github.com/python/cpython/issues/162092#top
testsTests in the Lib/test dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22tests%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/maikschulze
maikschulzehttps://github.com/maikschulze
on Nov 16, 2026https://github.com/python/cpython/issues/162092#issue-6417328431
#159718https://github.com/python/cpython/pull/159718
#157798https://github.com/python/cpython/pull/157798
e8c0584https://github.com/python/cpython/commit/e8c0584877e0b0a82ee8e0707336d8df4d68ccb4
7c59816https://github.com/python/cpython/commit/7c59816cb4d3db8387c454ce33d6b56c7d93fa6e
_PyCode_ShouldInternString()https://github.com/python/cpython/blob/e8c0584877e0/Objects/codeobject.c#L116-L137
writeshttps://github.com/python/cpython/blob/e8c0584877e0/Python/marshal.c#L1043-L1046
internshttps://github.com/python/cpython/blob/e8c0584877e0/Python/marshal.c#L1801-L1806
@vstinnerhttps://github.com/vstinner
gh-162092: Fix test_check_interned() of test_capi #162099https://github.com/python/cpython/pull/162099
[3.15] gh-162092: Fix test_check_interned() of test_capi (GH-162099) #162118https://github.com/python/cpython/pull/162118
[3.14] gh-162092: Fix test_check_interned() of test_capi (GH-162099) #162119https://github.com/python/cpython/pull/162119
maikschulzehttps://github.com/maikschulze
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Nov 16, 2026https://github.com/python/cpython/issues/162092#event-36254130954
https://github.com/maikschulze
maikschulzehttps://github.com/maikschulze
on Nov 16, 2026https://github.com/python/cpython/issues/162092#issuecomment-6911451546
main...maikschulze:cpython:gh-162092-test-check-internedhttps://github.com/python/cpython/compare/main...maikschulze:cpython:gh-162092-test-check-interned
aiskhttps://github.com/aisk
testsTests in the Lib/test dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22tests%22
on Nov 16, 2026https://github.com/python/cpython/issues/162092#event-36254428115
https://github.com/vstinner
vstinnerhttps://github.com/vstinner
on Nov 16, 2026https://github.com/python/cpython/issues/162092#issuecomment-6913579367
Hachoirhttps://github.com/vstinner/hachoir
https://github.com/vstinner
vstinnerhttps://github.com/vstinner
on Nov 16, 2026https://github.com/python/cpython/issues/162092#issuecomment-6913724975
gh-162092https://github.com/python/cpython/issues/162092
gh-162099https://github.com/python/cpython/pull/162099
https://github.com/maikschulze
maikschulzehttps://github.com/maikschulze
on Nov 16, 2026https://github.com/python/cpython/issues/162092#issuecomment-6915126087
@vstinnerhttps://github.com/vstinner
vstinnerhttps://github.com/vstinner
on Nov 16, 2026https://github.com/python/cpython/issues/162092#event-36297433516
gh-162092: Fix test_check_interned() of test_capi (#162099)https://github.com/python/cpython/commit/f4c13c80cdb9c350cf474ea5b9cf85245cbf89c7
gh-162092https://github.com/python/cpython/issues/162092
#162099https://github.com/python/cpython/pull/162099
f4c13c8https://github.com/python/cpython/commit/f4c13c80cdb9c350cf474ea5b9cf85245cbf89c7
[3.15] gh-162092: Fix test_check_interned() of test_capi (GH-162099) (#…https://github.com/python/cpython/commit/64974c33a9ff748b2dd92abb2491523b335572e7
gh-162092https://github.com/python/cpython/issues/162092
GH-162099https://github.com/python/cpython/pull/162099
#…https://github.com/python/cpython/pull/162118
64974c3https://github.com/python/cpython/commit/64974c33a9ff748b2dd92abb2491523b335572e7
[3.14] gh-162092: Fix test_check_interned() of test_capi (GH-162099) (#…https://github.com/python/cpython/commit/a637df9548836232aae6752645d3c205e12317b7
gh-162092https://github.com/python/cpython/issues/162092
GH-162099https://github.com/python/cpython/pull/162099
#…https://github.com/python/cpython/pull/162119
a637df9https://github.com/python/cpython/commit/a637df9548836232aae6752645d3c205e12317b7
https://github.com/vstinner
vstinnerhttps://github.com/vstinner
on Nov 16, 2026https://github.com/python/cpython/issues/162092#issuecomment-6923098393
vstinnerhttps://github.com/vstinner
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Nov 16, 2026https://github.com/python/cpython/issues/162092#event-36303022327
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/162092
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/162092
testsTests in the Lib/test dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22tests%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%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

Viewport: width=device-width


URLs of crawlers that visited me.