Title: Lazy imports fail to reload an unloaded parent package · Issue #162346 · python/cpython · GitHub
Open Graph Title: Lazy imports fail to reload an unloaded parent package · Issue #162346 · python/cpython
X Title: Lazy imports fail to reload an unloaded parent package · Issue #162346 · python/cpython
Description: Bug description: With all imports made lazy, the existing regression test for a relative import from an unloaded package fails: ./python -X lazy_imports=all -m test test_import -m test_import_from_unloaded_package -q It raises KeyError: ...
Open Graph Description: Bug description: With all imports made lazy, the existing regression test for a relative import from an unloaded package fails: ./python -X lazy_imports=all -m test test_import -m test_import_from_...
X Description: Bug description: With all imports made lazy, the existing regression test for a relative import from an unloaded package fails: ./python -X lazy_imports=all -m test test_import -m test_import_from_...
Opengraph URL: https://github.com/python/cpython/issues/162346
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Lazy imports fail to reload an unloaded parent package","articleBody":"### Bug description:\n\nWith all imports made lazy, the existing regression test for a relative import\nfrom an unloaded package fails:\n\n```console\n./python -X lazy_imports=all -m test test_import -m test_import_from_unloaded_package -q\n```\n\nIt raises `KeyError: 'package2'`. The test passes without\n`-X lazy_imports=all`.\n\n`package2.submodule1` removes `package2` from `sys.modules` and then imports\nanother submodule relatively. The eager import reloads the missing parent, but\nthe lazy import tries to bind the child while the parent is still absent.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nmacOS\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-162347\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/tonghuaroot","@type":"Person","name":"tonghuaroot"},"datePublished":"2026-11-21T02:10:19Z","url":"https://github.com/python/cpython/issues/162346"}
| 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:5fb204ce-6626-694c-8df5-d742febf7eb6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A654:31D532:11C8A31:17A3992:6B01E93E |
| html-safe-nonce | 0d1c3c18eae8b25cc8aff2b6dd604e088c5a0f708998a8fc49ff8dae4fb70c28 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjU0OjMxRDUzMjoxMUM4QTMxOjE3QTM5OTI6NkIwMUU5M0UiLCJ2aXNpdG9yX2lkIjoiNjc3MjY5NjU3MzIzMjE0Njc1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bcdf5c6f782abe9e42d705fed65a101f8ace797c71c63f36834496e1b16f6dcb |
| hovercard-subject-tag | issue:6523213947 |
| 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/162346/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cc49f8b94953a9baf857f86704b2043097471e74b712a0cb3d6f3efcd0a5c557/python/cpython/issues/162346 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cc49f8b94953a9baf857f86704b2043097471e74b712a0cb3d6f3efcd0a5c557/python/cpython/issues/162346 |
| og:image:alt | Bug description: With all imports made lazy, the existing regression test for a relative import from an unloaded package fails: ./python -X lazy_imports=all -m test test_import -m test_import_from_... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tonghuaroot |
| 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