René's URL Explorer Experiment


Title: `lazy import a.b as c` incorrectly binds to `a.b.b` · Issue #157614 · python/cpython · GitHub

Open Graph Title: `lazy import a.b as c` incorrectly binds to `a.b.b` · Issue #157614 · python/cpython

X Title: `lazy import a.b as c` incorrectly binds to `a.b.b` · Issue #157614 · python/cpython

Description: Bug report (Edited by @johnslavik) To reproduce: import importlib.metadata import importlib.metadata as x lazy import importlib.metadata as lazy_x print("type(x): ", type(x).__name__) # reifies to importlib.metadata print("type(lazy_x):"...

Open Graph Description: Bug report (Edited by @johnslavik) To reproduce: import importlib.metadata import importlib.metadata as x lazy import importlib.metadata as lazy_x print("type(x): ", type(x).__name__) # reifies to ...

X Description: Bug report (Edited by @johnslavik) To reproduce: import importlib.metadata import importlib.metadata as x lazy import importlib.metadata as lazy_x print("type(x): ", type(x).__name__) # r...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`lazy import a.b as c` incorrectly binds to `a.b.b`","articleBody":"# Bug report\n\n(Edited by @johnslavik)\n\nTo reproduce:\n\n```python\nimport importlib.metadata\nimport importlib.metadata as x\nlazy import importlib.metadata as lazy_x\n\nprint(\"type(x):     \", type(x).__name__)  # reifies to importlib.metadata\nprint(\"type(lazy_x):\", type(lazy_x).__name__)  # reifies to importlib.metadata.metadata\n\nx.distributions()  # OK\nlazy_x.distributions()  # AttributeError: 'function' object has no attribute 'distributions'\n```\n\n`x` is the `importlib.metadata` module, as expected. `lazy_x` is instead reified to `importlib.metadata.metadata`, the function.\n\nThe bug is in cached name resolution.\n\nFor `lazy import a.b as c`, the issue reproduces when:\n\n1. `a.b` is already in `sys.modules`.\n2. `a.b` has an attribute named `b`.\n3. `c` is reified.\n\n### Possible root cause\n\nThe problem may be in `_PyEval_LazyImportFrom`: [`[Python/ceval.c:3305-3361](https://github.com/python/cpython/blob/cf312cfa64dcaa1700531ec8bc76d56ddd65fb15/Python/ceval.c#L3305-L3361)`](https://github.com/python/cpython/blob/cf312cfa64dcaa1700531ec8bc76d56ddd65fb15/Python/ceval.c#L3305-L3361) (`3.15` at `cf312cfa64dcaa1700531ec8bc76d56ddd65fb15`, `v3.15.0rc2-22-gcf312cf`).\n\nThe `sys.modules` fast path at lines 3313-3331 runs before the base-module computation at 3333-3360 and looks up `name` directly in `d->lz_from`.\n\nIn the `IMPORT_FROM` chain generated for `import a.b.c as x`, however, `d->lz_from` does not appear to be the module the attribute should be taken from: on the first step it is the full dotted name, and on later steps it is one component short of the base.\n\n### CPython versions tested on:\n\n3.15\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-157626\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/grgalex","@type":"Person","name":"grgalex"},"datePublished":"2026-09-16T10:32:22Z","url":"https://github.com/python/cpython/issues/157614"}

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:c31a464f-722f-edc2-14d7-2788b4806dfd
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB52A:B53AF:3532235:46D0503:6B020261
html-safe-noncec0440e27feb43a13c8cd645588b70e0df874bf0137eb103cded474a9da4be995
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNTJBOkI1M0FGOjM1MzIyMzU6NDZEMDUwMzo2QjAyMDI2MSIsInZpc2l0b3JfaWQiOiI3ODc0NDg5MjQwOTU5MTg5NjAxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac8d1e3ee9858322267d1ed63126f0dadc96e8e3aeddfc60a42343ecdced97a9cc
hovercard-subject-tagissue:5473359343
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/157614/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6c5d950da443ce4053c42770c9347beae9bc47b8a488178581626057925990c4/python/cpython/issues/157614
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6c5d950da443ce4053c42770c9347beae9bc47b8a488178581626057925990c4/python/cpython/issues/157614
og:image:altBug report (Edited by @johnslavik) To reproduce: import importlib.metadata import importlib.metadata as x lazy import importlib.metadata as lazy_x print("type(x): ", type(x).__name__) # reifies to ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamegrgalex
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/157614#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F157614
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%2F157614
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/157614
Reloadhttps://github.com/python/cpython/issues/157614
Reloadhttps://github.com/python/cpython/issues/157614
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/157614
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/157614
#157626https://github.com/python/cpython/pull/157626
lazy import a.b as c incorrectly binds to a.b.bhttps://github.com/python/cpython/issues/157614#top
#157626https://github.com/python/cpython/pull/157626
3.15bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
3.16new features, bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.16%22
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-lazy-importshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-lazy-imports%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/grgalex
grgalexhttps://github.com/grgalex
on Sep 16, 2026https://github.com/python/cpython/issues/157614#issue-5473359343
@johnslavikhttps://github.com/johnslavik
[Python/ceval.c:3305-3361](https://github.com/python/cpython/blob/cf312cfa64dcaa1700531ec8bc76d56ddd65fb15/Python/ceval.c#L3305-L3361)https://github.com/python/cpython/blob/cf312cfa64dcaa1700531ec8bc76d56ddd65fb15/Python/ceval.c#L3305-L3361
gh-157614: Fix lazy import a.b as c incorrectly binding a.b.b #157626https://github.com/python/cpython/pull/157626
Nexthttps://github.com/python/cpython/issues/157614?timeline_page=1
grgalexhttps://github.com/grgalex
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Sep 16, 2026https://github.com/python/cpython/issues/157614#event-31237929222
grgalexhttps://github.com/grgalex
on Sep 16, 2026https://github.com/python/cpython/issues/157614#event-31239443022
pythongh-157614: Fix lazy import a.b as c binding a.b.b instead of th…https://github.com/grgalex/cpython/commit/d1de807cc3e4c494787d9decba360356a2f0fc99
pythongh-157614https://github.com/python/cpython/issues/157614
d1de807https://github.com/grgalex/cpython/commit/d1de807cc3e4c494787d9decba360356a2f0fc99
pythongh-157614: Fix lazy import a.b as c binding a.b.b instead of th…https://github.com/grgalex/cpython/commit/9858f12460deff41807101fb4abd6e71698bd461
pythongh-157614https://github.com/python/cpython/issues/157614
9858f12https://github.com/grgalex/cpython/commit/9858f12460deff41807101fb4abd6e71698bd461
johnslavikhttps://github.com/johnslavik
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
3.15bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
topic-lazy-importshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-lazy-imports%22
3.16new features, bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.16%22
on Sep 16, 2026https://github.com/python/cpython/issues/157614#event-31242887711
https://github.com/johnslavik
johnslavikhttps://github.com/johnslavik
on Sep 16, 2026https://github.com/python/cpython/issues/157614#issuecomment-5697099893
https://github.com/grgalex
grgalexhttps://github.com/grgalex
on Sep 16, 2026https://github.com/python/cpython/issues/157614#issuecomment-5697352599
@johnslavikhttps://github.com/johnslavik
https://github.com/johnslavik
johnslavikhttps://github.com/johnslavik
on Sep 16, 2026https://github.com/python/cpython/issues/157614#issuecomment-5697371943
@grgalexhttps://github.com/grgalex
grgalexhttps://github.com/grgalex
on Sep 16, 2026https://github.com/python/cpython/issues/157614#event-31244625863
pythongh-157614: Fix lazy import a.b as c binding a.b.b instead of th…https://github.com/grgalex/cpython/commit/fc21e6c6f8cf6feef01c38fb20d13e8ab7985025
pythongh-157614https://github.com/python/cpython/issues/157614
fc21e6chttps://github.com/grgalex/cpython/commit/fc21e6c6f8cf6feef01c38fb20d13e8ab7985025
pythongh-157614: Fix lazy import a.b as c binding a.b.b instead of th…https://github.com/grgalex/cpython/commit/1e7835b9684f74b0fd39f40ecf98e841c3fc0d7e
pythongh-157614https://github.com/python/cpython/issues/157614
1e7835bhttps://github.com/grgalex/cpython/commit/1e7835b9684f74b0fd39f40ecf98e841c3fc0d7e
pythongh-157614: Fix lazy import a.b as c binding a.b.b instead of th…https://github.com/grgalex/cpython/commit/88b63e1190711de72e5698f4700ed25fb6f01433
pythongh-157614https://github.com/python/cpython/issues/157614
88b63e1https://github.com/grgalex/cpython/commit/88b63e1190711de72e5698f4700ed25fb6f01433
pythongh-157614: Make the lazy import subprocess test helper reusablehttps://github.com/grgalex/cpython/commit/733be05df8a8e6f5566e33f2bd9234d14ba8c2ee
pythongh-157614https://github.com/python/cpython/issues/157614
733be05https://github.com/grgalex/cpython/commit/733be05df8a8e6f5566e33f2bd9234d14ba8c2ee
pythongh-157614: Fix lazy import a.b as c binding a.b.b instead of th…https://github.com/grgalex/cpython/commit/58c080fa2799c74e2188262ec6122f87762aed42
pythongh-157614https://github.com/python/cpython/issues/157614
58c080fhttps://github.com/grgalex/cpython/commit/58c080fa2799c74e2188262ec6122f87762aed42
grgalexhttps://github.com/grgalex
on Sep 16, 2026https://github.com/python/cpython/issues/157614#event-31249960257
pythongh-157614: Fix lazy import a.b as c binding a.b.b instead of th…https://github.com/grgalex/cpython/commit/6ec504af0f2729155271283c12dd3bb28d0b679c
pythongh-157614https://github.com/python/cpython/issues/157614
6ec504ahttps://github.com/grgalex/cpython/commit/6ec504af0f2729155271283c12dd3bb28d0b679c
pythongh-157614: Make the lazy import subprocess test helper reusablehttps://github.com/grgalex/cpython/commit/cfba96e4545ba990655a7ecb705b35118695502c
pythongh-157614https://github.com/python/cpython/issues/157614
cfba96ehttps://github.com/grgalex/cpython/commit/cfba96e4545ba990655a7ecb705b35118695502c
pythongh-157614: Fix lazy import a.b as c binding a.b.b instead of th…https://github.com/grgalex/cpython/commit/33988718f35c5c2bbe0c85516a221c61bd62c11a
pythongh-157614https://github.com/python/cpython/issues/157614
3398871https://github.com/grgalex/cpython/commit/33988718f35c5c2bbe0c85516a221c61bd62c11a
https://github.com/grgalex
grgalexhttps://github.com/grgalex
on Sep 16, 2026https://github.com/python/cpython/issues/157614#issuecomment-5699223926
@johnslavikhttps://github.com/johnslavik
StanFromIrelandhttps://github.com/StanFromIreland
release-blockerhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22release-blocker%22
on Sep 16, 2026https://github.com/python/cpython/issues/157614#event-31261142527
github-project-automationhttps://github.com/apps/github-project-automation
Release and Deferred blockers 🚫https://github.com/orgs/python/projects/2
on Sep 16, 2026https://github.com/python/cpython/issues/157614#event-31261405032
github-project-automationhttps://github.com/apps/github-project-automation
Release and Deferred blockers 🚫https://github.com/orgs/python/projects/2
on Sep 16, 2026https://github.com/python/cpython/issues/157614
https://github.com/StanFromIreland
StanFromIrelandhttps://github.com/StanFromIreland
on Sep 16, 2026https://github.com/python/cpython/issues/157614#issuecomment-5701141807
StanFromIrelandhttps://github.com/StanFromIreland
on Sep 16, 2026https://github.com/python/cpython/issues/157614#event-31261245519
https://github.com/grgalex
grgalexhttps://github.com/grgalex
on Sep 18, 2026https://github.com/python/cpython/issues/157614#issuecomment-5731784821
#157757https://github.com/python/cpython/issues/157757
https://github.com/hugovk
hugovkhttps://github.com/hugovk
on Sep 28, 2026https://github.com/python/cpython/issues/157614#issuecomment-5866775354
#158092https://github.com/python/cpython/pull/158092
#157626https://github.com/python/cpython/pull/157626
hugovkhttps://github.com/hugovk
release-blockerhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22release-blocker%22
on Sep 28, 2026https://github.com/python/cpython/issues/157614#event-31977609421
kevinprimeraquecreo-stackhttps://github.com/kevinprimeraquecreo-stack
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/157614#event-33592125057
github-project-automationhttps://github.com/apps/github-project-automation
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/157614
kevinprimeraquecreo-stackhttps://github.com/kevinprimeraquecreo-stack
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/157614#event-33592175616
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/157614
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/157614
3.15bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
3.16new features, bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.16%22
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-lazy-importshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-lazy-imports%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
Release and Deferred blockers 🚫https://github.com/orgs/python/projects/2
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.