Title: Lazy import triggers C assert if reading `spec._initializing` raises · Issue #158402 · python/cpython · GitHub
Open Graph Title: Lazy import triggers C assert if reading `spec._initializing` raises · Issue #158402 · python/cpython
X Title: Lazy import triggers C assert if reading `spec._initializing` raises · Issue #158402 · python/cpython
Description: Bug report Bug description: This has been crashing in debug mode since the initial lazy import implementation: import sys import types class Spec: @property def _initializing(self): raise RuntimeError("boom") module = types.ModuleType("c...
Open Graph Description: Bug report Bug description: This has been crashing in debug mode since the initial lazy import implementation: import sys import types class Spec: @property def _initializing(self): raise RuntimeEr...
X Description: Bug report Bug description: This has been crashing in debug mode since the initial lazy import implementation: import sys import types class Spec: @property def _initializing(self): raise RuntimeEr...
Opengraph URL: https://github.com/python/cpython/issues/158402
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Lazy import triggers C assert if reading `spec._initializing` raises","articleBody":"# Bug report\n\n### Bug description:\n\nThis has been crashing in debug mode since the initial lazy import implementation:\n```python\nimport sys\nimport types\n\nclass Spec:\n @property\n def _initializing(self):\n raise RuntimeError(\"boom\")\n\nmodule = types.ModuleType(\"cached_spec\")\nmodule.__spec__ = Spec()\nmodule.attr = 1\nsys.modules[\"cached_spec\"] = module\n\n# This line fails, but cannot be in a try block:\nlazy from cached_spec import attr\n```\n```text\npython3.15d: /builddir/build/BUILD/python3.15-3.15.0_rc2-build/Python-3.15.0rc2/Python/generated_cases.c.h:7979: _PyEval_EvalFrameDefault: Assertion `!_PyErr_Occurred(tstate)' failed.\nAborted (core dumped) python3.15d /tmp/repro.py\n```\n\n### CPython versions tested on:\n\n3.15, CPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-158403\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/encukou","@type":"Person","name":"encukou"},"datePublished":"2026-09-29T11:10:19Z","url":"https://github.com/python/cpython/issues/158402"}
| 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:5a428f0e-9195-2699-a203-8216007020ee |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 86CA:B1B84:2EC791A:3B87CA6:6B01F99F |
| html-safe-nonce | e170d23b66bba1ec3a666606e9a63eb6971521228f66e1e2858d82f66ca9fbdc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NkNBOkIxQjg0OjJFQzc5MUE6M0I4N0NBNjo2QjAxRjk5RiIsInZpc2l0b3JfaWQiOiI4MjUxODk0ODE2MTkxOTM2OTI3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 4e395bd26802f04728bcf0cb141789672bfcefd4627d1621c093fbe68879ebeb |
| hovercard-subject-tag | issue:5629560946 |
| 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/158402/issue_layout |
| twitter:image | https://opengraph.githubassets.com/297924b871f434a8a428f9cdeb3c67e50ba4abef6c45c55b1711d274a73a6577/python/cpython/issues/158402 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/297924b871f434a8a428f9cdeb3c67e50ba4abef6c45c55b1711d274a73a6577/python/cpython/issues/158402 |
| og:image:alt | Bug report Bug description: This has been crashing in debug mode since the initial lazy import implementation: import sys import types class Spec: @property def _initializing(self): raise RuntimeEr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | encukou |
| 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