Title: Import of submodule shadowing parent module attribute fails under lazy_imports mode · Issue #151208 · python/cpython · GitHub
Open Graph Title: Import of submodule shadowing parent module attribute fails under lazy_imports mode · Issue #151208 · python/cpython
X Title: Import of submodule shadowing parent module attribute fails under lazy_imports mode · Issue #151208 · python/cpython
Description: Bug report Bug description: For this module structure: └─ a/ ├─ __init__.py # Contains a function foo() └─ foo.py This script passes on 3.14: (edited: removed unnecessary from ... line) import a.foo import types assert isinstance(a.foo, ...
Open Graph Description: Bug report Bug description: For this module structure: └─ a/ ├─ __init__.py # Contains a function foo() └─ foo.py This script passes on 3.14: (edited: removed unnecessary from ... line) import a.fo...
X Description: Bug report Bug description: For this module structure: └─ a/ ├─ __init__.py # Contains a function foo() └─ foo.py This script passes on 3.14: (edited: removed unnecessary from ... line) import a.fo...
Opengraph URL: https://github.com/python/cpython/issues/151208
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Import of submodule shadowing parent module attribute fails under lazy_imports mode","articleBody":"# Bug report\n\n### Bug description:\n\nFor this module structure:\n```\n└─ a/\n ├─ __init__.py # Contains a function foo()\n └─ foo.py\n```\nThis script passes on 3.14: (edited: removed unnecessary `from ... ` line)\n```python\nimport a.foo\nimport types\nassert isinstance(a.foo, types.ModuleType), type(a.foo)\n```\nAnd fails on 3.15 with lazy imports (`python3.15 -X lazy_imports=all script.py`):\n```py\nTraceback (most recent call last):\n File \"/Users/jwalls/script.py\", line 3, in \u003cmodule>\n assert isinstance(a.foo, types.ModuleType), type(a.foo)\n ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^\nAssertionError: \u003cclass 'function'>\n```\n\n\n### CPython versions tested on:\n\n3.15\n\n### Operating systems tested on:\n\nmacOS","author":{"url":"https://github.com/jacobtylerwalls","@type":"Person","name":"jacobtylerwalls"},"datePublished":"2026-06-09T20:07:26Z","url":"https://github.com/python/cpython/issues/151208"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b4345632-1850-e2d7-0b2b-3e3864fcd7bb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C9E4:BB75:153AC39:1C1D28C:6B01FE70 |
| html-safe-nonce | d3eb663fe0bcd42290fff4ab6f4318b13ff78009d0bde43a3f026482fc5336ba |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOUU0OkJCNzU6MTUzQUMzOToxQzFEMjhDOjZCMDFGRTcwIiwidmlzaXRvcl9pZCI6IjI2ODYxNjMzMTQyNTc1NTkxNTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b9cff77487125aee7ed9d011bdbcf6a6b9b5866dd022ba37dc0c86174c803b0c |
| hovercard-subject-tag | issue:4625221139 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/151208/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b00a9c786f230b47b57d0fe09cc817ee327ec7f3973ba873157edcd1e7773861/python/cpython/issues/151208 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b00a9c786f230b47b57d0fe09cc817ee327ec7f3973ba873157edcd1e7773861/python/cpython/issues/151208 |
| og:image:alt | Bug report Bug description: For this module structure: └─ a/ ├─ __init__.py # Contains a function foo() └─ foo.py This script passes on 3.14: (edited: removed unnecessary from ... line) import a.fo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jacobtylerwalls |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width