René's URL Explorer Experiment


Title: Clarify pickle `__reduce__()` behavior when a string is returned (singleton support). · Issue #148669 · python/cpython · GitHub

Open Graph Title: Clarify pickle `__reduce__()` behavior when a string is returned (singleton support). · Issue #148669 · python/cpython

X Title: Clarify pickle `__reduce__()` behavior when a string is returned (singleton support). · Issue #148669 · python/cpython

Description: Documentation The documentation about __reduce__() mentions: cpython/Doc/library/pickle.rst Lines 693 to 696 in 2a07ff9 If a string is returned, the string should be interpreted as the name of a global variable. It should be the object's...

Open Graph Description: Documentation The documentation about __reduce__() mentions: cpython/Doc/library/pickle.rst Lines 693 to 696 in 2a07ff9 If a string is returned, the string should be interpreted as the name of a gl...

X Description: Documentation The documentation about __reduce__() mentions: cpython/Doc/library/pickle.rst Lines 693 to 696 in 2a07ff9 If a string is returned, the string should be interpreted as the name of a gl...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Clarify pickle `__reduce__()` behavior when a string is returned (singleton support).","articleBody":"### Documentation\n\nThe documentation about [`__reduce__()`](https://docs.python.org/3/library/pickle.html#object.__reduce__) mentions:\n\nhttps://github.com/python/cpython/blob/2a07ff980b412559f6cedafd432118684faa8d09/Doc/library/pickle.rst?plain=1#L693-L696\n\nIt is unclear what _the pickle module searches the module namespace to determine the object's module_ means, in particular whether for a specific `obj` to be pickled, the object's `__module__` is used (i.e. `obj.__module__`) or the module of the object's type (i.e. `type(obj).__module__`).\n\nWhile in most cases, it would be expected to look up on the class (as the `__module__` attribute is only [documented as being set on a class or function](https://docs.python.org/3/library/stdtypes.html#definition.__module__)), the current implementation does the attribute lookup on the object:\n\nhttps://github.com/python/cpython/blob/2a07ff980b412559f6cedafd432118684faa8d09/Lib/pickle.py#L336-L339\n\nThis behavior isn't clearly documented, but is relied on in multiple places, e.g. to [pickle functions](https://github.com/python/cpython/blob/2a07ff980b412559f6cedafd432118684faa8d09/Lib/pickle.py#L1270), [`TypeVar` instances](https://github.com/python/cpython/blob/2a07ff980b412559f6cedafd432118684faa8d09/Objects/typevarobject.c#L825-L835), the draft [PEP 661 implementation](https://github.com/JelleZijlstra/cpython/pull/4/changes#diff-68301e09a7fa43b9e8dfe94fb7b248c80db53503fde34d24566d66b8eaa274f8R104-R109) (and I believe [types themselves](https://github.com/python/cpython/blob/2a07ff980b412559f6cedafd432118684faa8d09/Lib/pickle.py#L597-L601)?)\n\nThis issue can be seen as a sub-issue of https://github.com/python/cpython/issues/60455.\n\nOriginal discussion about PEP 611 Sentinels can be found here: https://discuss.python.org/t/9126/262.\n\nI will have a PR up shortly.\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-148670\n* gh-149703\n* gh-149704\n* gh-149705\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/Viicos","@type":"Person","name":"Viicos"},"datePublished":"2026-04-17T09:01:40Z","url":"https://github.com/python/cpython/issues/148669"}

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:c87d7caa-e7f6-ad2d-9de2-1bf726e113ac
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBCA4:317608:39C1433:4929195:6B01F35A
html-safe-noncec0aaa4cc83137a8300e23f2f5023abf33d7db28eabc41902250641471e9d5454
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0E0OjMxNzYwODozOUMxNDMzOjQ5MjkxOTU6NkIwMUYzNUEiLCJ2aXNpdG9yX2lkIjoiODE1Mjg2OTQzMTc0MDA2ODY5OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac3ef192f3ddeae4d4db756547efe4949f6515c5df10e3121c09194b2525804d03
hovercard-subject-tagissue:4281395385
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/148669/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d72b70a7b0d52fc1bd8cdcf58b879effa4e15841aadfe89c0f4208c522342e1c/python/cpython/issues/148669
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d72b70a7b0d52fc1bd8cdcf58b879effa4e15841aadfe89c0f4208c522342e1c/python/cpython/issues/148669
og:image:altDocumentation The documentation about __reduce__() mentions: cpython/Doc/library/pickle.rst Lines 693 to 696 in 2a07ff9 If a string is returned, the string should be interpreted as the name of a gl...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameViicos
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
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
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/148669#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F148669
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%2F148669
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/148669
Reloadhttps://github.com/python/cpython/issues/148669
Reloadhttps://github.com/python/cpython/issues/148669
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/148669
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/148669
Clarify pickle __reduce__() behavior when a string is returned (singleton support).https://github.com/python/cpython/issues/148669#top
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
https://github.com/Viicos
Viicoshttps://github.com/Viicos
on Apr 17, 2026https://github.com/python/cpython/issues/148669#issue-4281395385
__reduce__()https://docs.python.org/3/library/pickle.html#object.__reduce__
cpython/Doc/library/pickle.rsthttps://github.com/python/cpython/blob/2a07ff980b412559f6cedafd432118684faa8d09/Doc/library/pickle.rst?plain=1#L693-L696
2a07ff9https://github.com/python/cpython/commit/2a07ff980b412559f6cedafd432118684faa8d09
documented as being set on a class or functionhttps://docs.python.org/3/library/stdtypes.html#definition.__module__
cpython/Lib/pickle.pyhttps://github.com/python/cpython/blob/2a07ff980b412559f6cedafd432118684faa8d09/Lib/pickle.py#L336-L339
2a07ff9https://github.com/python/cpython/commit/2a07ff980b412559f6cedafd432118684faa8d09
pickle functionshttps://github.com/python/cpython/blob/2a07ff980b412559f6cedafd432118684faa8d09/Lib/pickle.py#L1270
TypeVar instanceshttps://github.com/python/cpython/blob/2a07ff980b412559f6cedafd432118684faa8d09/Objects/typevarobject.c#L825-L835
PEP 661 implementationhttps://github.com/JelleZijlstra/cpython/pull/4/changes#diff-68301e09a7fa43b9e8dfe94fb7b248c80db53503fde34d24566d66b8eaa274f8R104-R109
types themselveshttps://github.com/python/cpython/blob/2a07ff980b412559f6cedafd432118684faa8d09/Lib/pickle.py#L597-L601
#60455https://github.com/python/cpython/issues/60455
https://discuss.python.org/t/9126/262https://discuss.python.org/t/9126/262
gh-148669: Clarify __reduce__() module lookup behavior #148670https://github.com/python/cpython/pull/148670
[3.15] gh-148669: Clarify __reduce__() module lookup behavior (GH-148670) #149703https://github.com/python/cpython/pull/149703
[3.14] gh-148669: Clarify __reduce__() module lookup behavior (GH-148670) #149704https://github.com/python/cpython/pull/149704
[3.13] gh-148669: Clarify __reduce__() module lookup behavior (GH-148670) #149705https://github.com/python/cpython/pull/149705
Viicoshttps://github.com/Viicos
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
on Apr 17, 2026https://github.com/python/cpython/issues/148669#event-24600092095
github-project-automationhttps://github.com/apps/github-project-automation
docs issueshttps://github.com/orgs/python/projects/52
on Apr 17, 2026https://github.com/python/cpython/issues/148669
github-project-automationhttps://github.com/apps/github-project-automation
docs issueshttps://github.com/orgs/python/projects/52
on Apr 17, 2026https://github.com/python/cpython/issues/148669#event-24600095889
StanFromIrelandhttps://github.com/StanFromIreland
Pickle and copy issues 🥒https://github.com/orgs/python/projects/9
on Apr 17, 2026https://github.com/python/cpython/issues/148669#event-24614683317
JelleZijlstrahttps://github.com/JelleZijlstra
on May 12, 2026https://github.com/python/cpython/issues/148669#event-25410900025
gh-148669: Clarify `__reduce__()` module lookup behavior (#148670)https://github.com/python/cpython/commit/54a5fd4126df74f7b84d1f8a6a36ef79803f66f9
gh-148669https://github.com/python/cpython/issues/148669
#148670https://github.com/python/cpython/pull/148670
54a5fd4https://github.com/python/cpython/commit/54a5fd4126df74f7b84d1f8a6a36ef79803f66f9
[3.13] gh-148669: Clarify `__reduce__()` module lookup behavior (GH-1…https://github.com/python/cpython/commit/ae65e0cf85b5528e8c05d71fb5ff3ed77c8cd7b6
gh-148669https://github.com/python/cpython/issues/148669
GH-1…https://github.com/python/cpython/pull/148670
ae65e0chttps://github.com/python/cpython/commit/ae65e0cf85b5528e8c05d71fb5ff3ed77c8cd7b6
[3.14] gh-148669: Clarify `__reduce__()` module lookup behavior (GH-1…https://github.com/python/cpython/commit/49bf2d1cbd1ee3022dffed1af50c40b3a66238bb
gh-148669https://github.com/python/cpython/issues/148669
GH-1…https://github.com/python/cpython/pull/148670
49bf2d1https://github.com/python/cpython/commit/49bf2d1cbd1ee3022dffed1af50c40b3a66238bb
[3.15] gh-148669: Clarify `__reduce__()` module lookup behavior (GH-1…https://github.com/python/cpython/commit/9138bf2612730f8d6bca46e08f645072c7bf32fa
gh-148669https://github.com/python/cpython/issues/148669
GH-1…https://github.com/python/cpython/pull/148670
9138bf2https://github.com/python/cpython/commit/9138bf2612730f8d6bca46e08f645072c7bf32fa
Viicoshttps://github.com/Viicos
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on May 12, 2026https://github.com/python/cpython/issues/148669#event-25417880992
github-project-automationhttps://github.com/apps/github-project-automation
Pickle and copy issues 🥒https://github.com/orgs/python/projects/9
on May 12, 2026https://github.com/python/cpython/issues/148669
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/148669
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/148669
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
Pickle and copy issues 🥒https://github.com/orgs/python/projects/9
docs issueshttps://github.com/orgs/python/projects/52
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.