Title: Importing module with capsule attribute fails in sub interpreter · Issue #112100 · python/cpython · GitHub
Open Graph Title: Importing module with capsule attribute fails in sub interpreter · Issue #112100 · python/cpython
X Title: Importing module with capsule attribute fails in sub interpreter · Issue #112100 · python/cpython
Description: Bug report Bug description: When importing certain modules (zoneinfo is an example), attributes are missing when inside a sub interpreter. Importing these modules works inside the main interpreter. I've written a test to demonstrate the ...
Open Graph Description: Bug report Bug description: When importing certain modules (zoneinfo is an example), attributes are missing when inside a sub interpreter. Importing these modules works inside the main interpreter....
X Description: Bug report Bug description: When importing certain modules (zoneinfo is an example), attributes are missing when inside a sub interpreter. Importing these modules works inside the main interpreter....
Opengraph URL: https://github.com/python/cpython/issues/112100
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Importing module with capsule attribute fails in sub interpreter","articleBody":"# Bug report\n\n### Bug description:\n\nWhen importing certain modules (`zoneinfo` is an example), attributes are missing when inside a sub interpreter.\n\nImporting these modules works inside the main interpreter. \n\nI've written a test to demonstrate the bug\n\n```python\nimport unittest\nimport _xxsubinterpreters as interpreters\n\n\nclass TestCapsule(unittest.TestCase):\n\n def test_capsule(self):\n import zoneinfo\n\n def test_capsule_in_sub_interpreter(self):\n interp = interpreters.create()\n interpreters.run_string(interp, \"import zoneinfo\")\n```\n\n```default\n.Traceback (most recent call last):\n File \"\u003cstring\u003e\", line 1, in \u003cmodule\u003e\n File \"/usr/local/lib/python3.13/zoneinfo/__init__.py\", line 14, in \u003cmodule\u003e\n from _zoneinfo import ZoneInfo\nAttributeError: module 'datetime' has no attribute 'datetime_CAPI'\nE\n======================================================================\nERROR: test_capsule_in_sub_interpreter (test_capsule.TestCapsule.test_capsule_in_sub_interpreter)\n----------------------------------------------------------------------\nTraceback (most recent call last):\n File \"/Users/anthonyshaw/projects/subinterpreter-web/test_capsule.py\", line 12, in test_capsule_in_sub_interpreter\n interpreters.run_string(interp, \"import zoneinfo\")\n_xxsubinterpreters.RunFailedError: AttributeError: module 'datetime' has no attribute 'datetime_CAPI'\n\n----------------------------------------------------------------------\nRan 2 tests in 0.457s\n\nFAILED (errors=1)\n```\n\nI haven't seen this behaviour on any other modules, the thing that seemed special with `datetime` and this attribute is that it is a PyCapsule. So the issue is likely related to that?\n\n### CPython versions tested on:\n\n3.13, CPython main branch\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-112101\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/tonybaloney","@type":"Person","name":"tonybaloney"},"datePublished":"2023-11-15T03:25:42.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/112100/cpython/issues/112100"}
| 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:940bb036-c20e-25b3-c6a3-bd13c765bb43 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A62C:1301FE:106F22A:15F1303:69699244 |
| html-safe-nonce | 454d6f090d76db0234f7ff9390b89d0eed240647180f994d2b47f14732545934 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjJDOjEzMDFGRToxMDZGMjJBOjE1RjEzMDM6Njk2OTkyNDQiLCJ2aXNpdG9yX2lkIjoiMzM2Mjc4MDE2OTg0NjIzMTYyMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ca1251d268f9db50a4c595bf8dcc089420f8005d13c8122cbcbea09bc0412994 |
| hovercard-subject-tag | issue:1993966185 |
| 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/112100/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4f98cbfb0712c5e848e708c19de498295238cbaef2e6bd973c88c74d9c4a7503/python/cpython/issues/112100 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4f98cbfb0712c5e848e708c19de498295238cbaef2e6bd973c88c74d9c4a7503/python/cpython/issues/112100 |
| og:image:alt | Bug report Bug description: When importing certain modules (zoneinfo is an example), attributes are missing when inside a sub interpreter. Importing these modules works inside the main interpreter.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tonybaloney |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3542e147982176a7ebaa23dfb559c8af16f721c03ec560c68c56b64a0f35e751 |
| 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 | af80af7cc9e3de9c336f18b208a600950a3c187c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width