René's URL Explorer Experiment


Title: Lazy submodule imports hide exceptions raised while loading the submodule · Issue #153236 · python/cpython · GitHub

Open Graph Title: Lazy submodule imports hide exceptions raised while loading the submodule · Issue #153236 · python/cpython

X Title: Lazy submodule imports hide exceptions raised while loading the submodule · Issue #153236 · python/cpython

Description: Bug report Bug description: Accessing a pending lazy submodule through the parent module can hide the real exception raised while importing the submodule. Reproducer: mkdir -p lel/lol printf 'print("LEL")\n' > lel/__init__.py printf '1/0...

Open Graph Description: Bug report Bug description: Accessing a pending lazy submodule through the parent module can hide the real exception raised while importing the submodule. Reproducer: mkdir -p lel/lol printf 'print...

X Description: Bug report Bug description: Accessing a pending lazy submodule through the parent module can hide the real exception raised while importing the submodule. Reproducer: mkdir -p lel/lol printf 'p...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Lazy submodule imports hide exceptions raised while loading the submodule","articleBody":"# Bug report\n\n### Bug description:\n\nAccessing a pending lazy submodule through the parent module can hide the real\nexception raised while importing the submodule.\n\nReproducer:\n\n```sh\nmkdir -p lel/lol\nprintf 'print(\"LEL\")\\n' > lel/__init__.py\nprintf '1/0\\n' > lel/lol/__init__.py\n./python -c 'lazy import lel.lol; lel.lol'\n```\n\nActual output:\n\n```py\nTraceback (most recent call last):\n  File \"\u003cstring>\", line 1, in \u003cmodule>\n    lazy import lel.lol; lel.lol\n                         ^^^^^^^\nAttributeError: module 'lel' has no attribute 'lol'\nLEL\n```\n\nThe eager import is much easier to debug:\n\n```sh\n./python -c 'import lel.lol; lel.lol'\n```\n\n```py\nTraceback (most recent call last):\n  File \"\u003cstring>\", line 1, in \u003cmodule>\n    import lel.lol; lel.lol\n    ^^^^^^^^^^^^^^\n  File \"/tmp/lazy-issue-repro/lel/lol/__init__.py\", line 1, in \u003cmodule>\n    1/0\n    ~^~\nZeroDivisionError: division by zero\nLEL\n```\n\nI would expect the lazy import path to propagate the exception raised while\nexecuting `lel.lol`, probably with the lazy-import reification chain, instead\nof turning it into a missing attribute on `lel`.\n\nUnless I am missing something, this is coming from\n`Objects/moduleobject.c:try_load_lazy_submodule()`. It calls\n`_PyImport_TryLoadLazySubmodule()`, and if that returns `NULL`, it clears the\nactive exception:\n\n```c\nPyObject *result = _PyImport_TryLoadLazySubmodule(mod_name, name);\nPy_DECREF(mod_name);\nif (result == NULL) {\n    PyErr_Clear();\n    return NULL;\n}\n```\n\nBut `_PyImport_TryLoadLazySubmodule()` calls `PyImport_ImportModuleLevelObject()`,\nso `NULL` can mean that the pending submodule exists but failed while importing,\nnot only that the attribute should fall through to normal `AttributeError`\nhandling.\n\nThis seems related to gh-150052 / gh-150744, but it looks different from\ngh-151208: there is no parent attribute shadowing here, the child module itself\nraises during import.\n\n### CPython versions tested on:\n\nCPython main branch\n\nTested on a local `3.16.0a0` main-derived build at `8b59df84c0d`, containing\n`5a2d2736a655d993934adee1bbb568067d53f6f4`.\n\n### Operating systems tested on:\n\nLinux\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-153237\n* gh-153936\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/pablogsal","@type":"Person","name":"pablogsal"},"datePublished":"2026-07-06T20:01:48Z","url":"https://github.com/python/cpython/issues/153236"}

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:7e4e57fe-9b6a-b740-a03b-392c804a4ad9
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8F62:3DD488:378F9AA:46A639C:6B01F34D
html-safe-nonce3a8fed971c4573ed96995fb6b9f4f8f94e73800245dde2d404f3ae32ebef8c71
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RjYyOjNERDQ4ODozNzhGOUFBOjQ2QTYzOUM6NkIwMUYzNEQiLCJ2aXNpdG9yX2lkIjoiMjg4NzU5MzgwNTgxMTQxMzgzOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac60660ef5471407f0f7d03a4d5067cf7b8651c227c422f9c436e6a4cda6490b7f
hovercard-subject-tagissue:4822663789
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/153236/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6464bd783452cd88c159530f955c9b6c13a7d4b193be3054fd27fbf2f077fc3d/python/cpython/issues/153236
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6464bd783452cd88c159530f955c9b6c13a7d4b193be3054fd27fbf2f077fc3d/python/cpython/issues/153236
og:image:altBug report Bug description: Accessing a pending lazy submodule through the parent module can hide the real exception raised while importing the submodule. Reproducer: mkdir -p lel/lol printf 'print...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamepablogsal
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/153236#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F153236
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%2F153236
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/153236
Reloadhttps://github.com/python/cpython/issues/153236
Reloadhttps://github.com/python/cpython/issues/153236
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/153236
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/153236
Lazy submodule imports hide exceptions raised while loading the submodulehttps://github.com/python/cpython/issues/153236#top
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/pablogsal
pablogsalhttps://github.com/pablogsal
on Jul 6, 2026https://github.com/python/cpython/issues/153236#issue-4822663789
gh-150052https://github.com/python/cpython/issues/150052
gh-150744https://github.com/python/cpython/pull/150744
gh-151208https://github.com/python/cpython/issues/151208
gh-153236: Propagate lazy submodule import errors #153237https://github.com/python/cpython/pull/153237
[3.15] gh-153236: Propagate lazy submodule import errors (GH-153237) #153936https://github.com/python/cpython/pull/153936
pablogsalhttps://github.com/pablogsal
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%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
on Jul 6, 2026https://github.com/python/cpython/issues/153236#event-27629104626
pablogsalhttps://github.com/pablogsal
on Jul 6, 2026https://github.com/python/cpython/issues/153236#event-27635910091
pythongh-153236: Propagate lazy submodule import errorshttps://github.com/pablogsal/cpython/commit/1c296cfca5408d89cccc504ad349dbdf7dcad83c
pythongh-153236https://github.com/python/cpython/issues/153236
1c296cfhttps://github.com/pablogsal/cpython/commit/1c296cfca5408d89cccc504ad349dbdf7dcad83c
pablogsalhttps://github.com/pablogsal
on Jul 18, 2026https://github.com/python/cpython/issues/153236#event-28157532873
pythongh-153236: Propagate lazy submodule import errorshttps://github.com/pablogsal/cpython/commit/d183e5fb9a5f7c6c27e58f3fd4b7edeb6038c252
pythongh-153236https://github.com/python/cpython/issues/153236
d183e5fhttps://github.com/pablogsal/cpython/commit/d183e5fb9a5f7c6c27e58f3fd4b7edeb6038c252
pythongh-153236: Propagate lazy submodule import errorshttps://github.com/pablogsal/cpython/commit/9a64b352ed3fd34defa6a499155cbe22ea498740
pythongh-153236https://github.com/python/cpython/issues/153236
9a64b35https://github.com/pablogsal/cpython/commit/9a64b352ed3fd34defa6a499155cbe22ea498740
gh-153236: Propagate lazy submodule import errors (#153237)https://github.com/python/cpython/commit/0a09dafb03dae17895d4a86af04985e373bbdceb
gh-153236https://github.com/python/cpython/issues/153236
#153237https://github.com/python/cpython/pull/153237
0a09dafhttps://github.com/python/cpython/commit/0a09dafb03dae17895d4a86af04985e373bbdceb
pablogsalhttps://github.com/pablogsal
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jul 18, 2026https://github.com/python/cpython/issues/153236#event-28158421833
pablogsalhttps://github.com/pablogsal
on Jul 18, 2026https://github.com/python/cpython/issues/153236#event-28161893896
[3.15] gh-153236: Propagate lazy submodule import errors (GH-153237) (#…https://github.com/python/cpython/commit/0cb0723178c975eec1d5ca1ea6dc72d2eda13e16
gh-153236https://github.com/python/cpython/issues/153236
GH-153237https://github.com/python/cpython/pull/153237
#…https://github.com/python/cpython/pull/153936
0cb0723https://github.com/python/cpython/commit/0cb0723178c975eec1d5ca1ea6dc72d2eda13e16
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/153236
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/153236
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
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.