René's URL Explorer Experiment


Title: LOAD_ATTR_MODULE bypasses built-in data descriptors on exact module objects · Issue #162565 · python/cpython · GitHub

Open Graph Title: LOAD_ATTR_MODULE bypasses built-in data descriptors on exact module objects · Issue #162565 · python/cpython

X Title: LOAD_ATTR_MODULE bypasses built-in data descriptors on exact module objects · Issue #162565 · python/cpython

Description: Bug report On current main at 79494e2, warmed attribute reads on an exact types.ModuleType object can return dictionary entries named __dict__ or __class__ instead of the built-in data descriptor results. Cold reads and getattr() return ...

Open Graph Description: Bug report On current main at 79494e2, warmed attribute reads on an exact types.ModuleType object can return dictionary entries named __dict__ or __class__ instead of the built-in data descriptor r...

X Description: Bug report On current main at 79494e2, warmed attribute reads on an exact types.ModuleType object can return dictionary entries named __dict__ or __class__ instead of the built-in data descriptor r...

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

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":"LOAD_ATTR_MODULE bypasses built-in data descriptors on exact module objects","articleBody":"### Bug report\n\nOn current `main` at 79494e2b0f7e9e1cc3a39fe035e67cea33c7ef0a, warmed attribute reads on an **exact** `types.ModuleType` object can return dictionary entries named `__dict__` or `__class__` instead of the built-in data descriptor results. Cold reads and `getattr()` return the descriptor results on the same object.\n\n```python\nimport dis\nimport types\n\nmodule = types.ModuleType(\"example\")\nnamespace = vars(module)\nnamespace[\"__dict__\"] = \"shadow dict\"\nnamespace[\"__class__\"] = \"shadow class\"\n\n\ndef read_dict(owner):\n    return owner.__dict__\n\n\ndef read_class(owner):\n    return owner.__class__\n\n\nprint(\"Exact module:\", type(module) is types.ModuleType)\nfor name, read, expected in (\n    (\"__dict__\", read_dict, namespace),\n    (\"__class__\", read_class, types.ModuleType),\n):\n    print(name)\n    print(\"  cold uses descriptor:\", read(module) is expected)\n    for _ in range(100):\n        read(module)\n    print(\"  warm uses descriptor:\", read(module) is expected)\n    print(\"  warm returns shadow:\", read(module) is namespace[name])\n    print(\"  getattr uses descriptor:\", getattr(module, name) is expected)\n    print(\"  attribute opcodes:\", [\n        op.opname for op in dis.get_instructions(read, adaptive=True)\n        if \"LOAD_ATTR\" in op.opname\n    ])\n```\n\nObserved output:\n\n```text\nExact module: True\n__dict__\n  cold uses descriptor: True\n  warm uses descriptor: False\n  warm returns shadow: True\n  getattr uses descriptor: True\n  attribute opcodes: ['LOAD_ATTR_MODULE']\n__class__\n  cold uses descriptor: True\n  warm uses descriptor: False\n  warm returns shadow: True\n  getattr uses descriptor: True\n  attribute opcodes: ['LOAD_ATTR_MODULE']\n```\n\nExpected: both cold and warmed reads preserve descriptor precedence. `__dict__` should return the module namespace and `__class__` should return `types.ModuleType`, regardless of these dictionary entries. Thus `warm uses descriptor` should be `True`, and `warm returns shadow` should be `False` for both names.\n\nThis is distinct from #156399: no module subclass or user-defined descriptor is involved. Its fix, #156474, is already an ancestor of the tested commit and restricts module specialization to exact modules. The existing `test_load_attr_module_subclass_with_data_descriptor` passes on this build while the example above still produces the wrong warmed results.\n\nIn the tested source, [module specialization](https://github.com/python/cpython/blob/79494e2b0f7e9e1cc3a39fe035e67cea33c7ef0a/Python/specialize.c#L413-L446) selects the dictionary entry without checking for a data descriptor on the module type. The [specialized instruction](https://github.com/python/cpython/blob/79494e2b0f7e9e1cc3a39fe035e67cea33c7ef0a/Python/bytecodes.c#L2893-L2916) then reads that entry directly.\n\n### CPython versions tested on\n\nCPython main branch, `3.16.0a2+dev`, clean checkout at [79494e2b0f7](https://github.com/python/cpython/commit/79494e2b0f7e9e1cc3a39fe035e67cea33c7ef0a), fetched and built on 2026-11-24. Released versions were not checked for this report.\n\n### Operating systems tested on\n\nmacOS 27.2.1, ARM64, Apple Clang 21.0.0. Fresh debug build configured with `--with-pydebug --without-ensurepip`; GIL enabled, JIT unavailable. The example was run with `./python.exe -I repro.py`.\n\nThe related subclass control was run with:\n\n```sh\n./python.exe -I -m test test_opcache -m test_load_attr_module_subclass_with_data_descriptor -v\n```\n\nResult: one test passed; this was a focused check, not a full test-suite run.\n\nPrepared with Codex assistance; the included reproducer and subclass control were executed on the stated upstream checkout.\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-162568\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/lagergren-oai","@type":"Person","name":"lagergren-oai"},"datePublished":"2026-11-24T16:29:54Z","url":"https://github.com/python/cpython/issues/162565"}

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:3610764d-e9a3-9b8a-4b9e-7dd2f63f21d2
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD210:3FD98D:B744B5:F39DB7:6B06420C
html-safe-nonce01a3a14b1ed817f13fb03fff00784ef128ef615b9912478f661c2371e801a46c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjEwOjNGRDk4RDpCNzQ0QjU6RjM5REI3OjZCMDY0MjBDIiwidmlzaXRvcl9pZCI6Ijc1Nzk4Mjk4NDQyMjY0OTA4OTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac26eaf6c370540ae6bb51e671d6b88a40e45ad5993b8b18bc4abd4e1a5005af1c
hovercard-subject-tagissue:6586542985
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/162565/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a75cc9c82d1d2dc440c81b577d6eded294a486c113ba04df27ed8a7ba40fa22f/python/cpython/issues/162565
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a75cc9c82d1d2dc440c81b577d6eded294a486c113ba04df27ed8a7ba40fa22f/python/cpython/issues/162565
og:image:altBug report On current main at 79494e2, warmed attribute reads on an exact types.ModuleType object can return dictionary entries named __dict__ or __class__ instead of the built-in data descriptor r...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamelagergren-oai
hostnamegithub.com
expected-hostnamegithub.com
None1bff4f6bfaa96dc9c42cacf315424c24ebb548b06142ced5e3aaccb2a42dd652
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
releaseac613d3698d3d8565651455086e1f74da07bf277
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/162565#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F162565
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%2F162565
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/162565
Reloadhttps://github.com/python/cpython/issues/162565
Reloadhttps://github.com/python/cpython/issues/162565
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/162565
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/162565
#162568https://github.com/python/cpython/pull/162568
LOAD_ATTR_MODULE bypasses built-in data descriptors on exact module objectshttps://github.com/python/cpython/issues/162565#top
#162568https://github.com/python/cpython/pull/162568
interpreter-corehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-bughttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/lagergren-oai
lagergren-oaihttps://github.com/lagergren-oai
on Nov 24, 2026https://github.com/python/cpython/issues/162565#issue-6586542985
79494e2https://github.com/python/cpython/commit/79494e2b0f7e9e1cc3a39fe035e67cea33c7ef0a
#156399https://github.com/python/cpython/issues/156399
#156474https://github.com/python/cpython/pull/156474
module specializationhttps://github.com/python/cpython/blob/79494e2b0f7e9e1cc3a39fe035e67cea33c7ef0a/Python/specialize.c#L413-L446
specialized instructionhttps://github.com/python/cpython/blob/79494e2b0f7e9e1cc3a39fe035e67cea33c7ef0a/Python/bytecodes.c#L2893-L2916
79494e2b0f7https://github.com/python/cpython/commit/79494e2b0f7e9e1cc3a39fe035e67cea33c7ef0a
gh-162565: Preserve module data descriptor precedence during specialization #162568https://github.com/python/cpython/pull/162568
picnixzhttps://github.com/picnixz
type-bughttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
interpreter-corehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
on Nov 24, 2026https://github.com/python/cpython/issues/162565#event-37154702725
https://github.com/lagergren
lagergrenhttps://github.com/lagergren
on Nov 24, 2026https://github.com/python/cpython/issues/162565#issuecomment-7138863850
#162568https://github.com/python/cpython/pull/162568
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/162565
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/162565
interpreter-corehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-bughttps://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

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.