Title: Forcing enabling the GIL doesn't seem to work with PEP 793 initialization · Issue #141780 · python/cpython · GitHub
Open Graph Title: Forcing enabling the GIL doesn't seem to work with PEP 793 initialization · Issue #141780 · python/cpython
X Title: Forcing enabling the GIL doesn't seem to work with PEP 793 initialization · Issue #141780 · python/cpython
Description: Bug report Bug description: #include
Open Graph Description: Bug report Bug description: #include
X Description: Bug report Bug description: #include <Python.h> static int examplemodule_exec(PyObject *module) { // Yes I know there's no error checking... PyObject *gil_enabled = PySys_GetObject("...
Opengraph URL: https://github.com/python/cpython/issues/141780
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Forcing enabling the GIL doesn't seem to work with PEP 793 initialization","articleBody":"# Bug report\n\n### Bug description:\n\n```c\n#include \u003cPython.h>\n\nstatic int\nexamplemodule_exec(PyObject *module) {\n // Yes I know there's no error checking...\n PyObject *gil_enabled = PySys_GetObject(\"_is_gil_enabled\");\n PyObject *result = PyObject_CallNoArgs(gil_enabled);\n printf(\"gil enabled: \");\n PyObject_Print(result, stdout, 0);\n printf(\"\\n\");\n Py_DECREF(result);\n return 0;\n}\n\nstatic PyModuleDef_Slot examplemodule_slots[] = {\n {Py_mod_name, \"examplemodule\"},\n {Py_mod_gil, Py_MOD_GIL_USED},\n {Py_mod_exec, (void*)examplemodule_exec},\n {0}\n};\n\nPyMODEXPORT_FUNC\nPyModExport_examplemodule(void)\n{\n return examplemodule_slots;\n}\n```\n\nI believe that the code above should print \"gil enabled: True\". However when I run it on Python 3.15.0a2 freethreading it prints \"gil enabled: False\".\n\nI don't believe this is an issue in the old style `PyInit_` initialization.\n\n### CPython versions tested on:\n\n3.15\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-141785\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/da-woods","@type":"Person","name":"da-woods"},"datePublished":"2025-11-20T08:10:04Z","url":"https://github.com/python/cpython/issues/141780"}
| 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:1b5b5f77-c64a-2538-248e-c9af2047b86d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CEDE:BACA4:33EF45F:4511A62:6B004487 |
| html-safe-nonce | 6fbda959bdfb261f918f2323c7e1618588c1d08215db0257cdf1622d701584ae |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRURFOkJBQ0E0OjMzRUY0NUY6NDUxMUE2Mjo2QjAwNDQ4NyIsInZpc2l0b3JfaWQiOiI5MDA4NTc5MjU1Mjk4MTgwMjMxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e802714d33a918d8608c8891b76dd50d0eac766c7a95e6da7d3a0b9b2bfb4ab5 |
| hovercard-subject-tag | issue:3646006480 |
| 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/141780/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3a9ab6eaecdad9af828b59376561a99871748163adb96ec96cd555abcd738d5b/python/cpython/issues/141780 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3a9ab6eaecdad9af828b59376561a99871748163adb96ec96cd555abcd738d5b/python/cpython/issues/141780 |
| og:image:alt | Bug report Bug description: #include |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | da-woods |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width