Title: Isolate the _curses extension module · Issue #101714 · python/cpython · GitHub
Open Graph Title: Isolate the _curses extension module · Issue #101714 · python/cpython
X Title: Isolate the _curses extension module · Issue #101714 · python/cpython
Description: Feature or enhancement Isolate the _curses extension module. This means turning most global variables into module state variables. Globals in the _curses extension module: Name C type Notes PyCursesVersion const char[] Hard-coded C strin...
Open Graph Description: Feature or enhancement Isolate the _curses extension module. This means turning most global variables into module state variables. Globals in the _curses extension module: Name C type Notes PyCurse...
X Description: Feature or enhancement Isolate the _curses extension module. This means turning most global variables into module state variables. Globals in the _curses extension module: Name C type Notes PyCurse...
Opengraph URL: https://github.com/python/cpython/issues/101714
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Isolate the _curses extension module","articleBody":"# Feature or enhancement\r\n\r\nIsolate the `_curses` extension module. This means turning most global variables into module state variables.\r\n\r\nGlobals in the `_curses` extension module:\r\n\r\n| Name | C type | Notes |\r\n| --- | --- | --- |\r\n| PyCursesVersion | const char[] | Hard-coded C string; can remain a global |\r\n| PyCursesError | PyObject \\* |\r\n| initialised\\_setupterm | int | Tells whether `setupterm()` has been called to initialise `terminfo` |\r\n| initialised | int | Tells whether `initscr()` has been called to initialise curses |\r\n| initialisedcolors | int | Tells whether `start_color()` has been called to initialise color usage |\r\n| screen\\_encoding | int |\r\n| PyCursesWindow_Type | PyTypeObject \\* | Must convert to heap type |\r\n| ModDict | PyObject \\* |\r\n\r\nThere is also a capsule with a C API. I'm not sure if this needs special handling wrt. PEP-489, but the \\_curses C API exposes three of the global variables[^1] directly. That said, those three variables are all guards for curses specific initialisation; it may make sense to keep these variables global; I don't know yet. The capsule C API also uses the \\_curses exception object (`curses.error`). Altering or removing the \\_curses C API is a breaking change and must follow the deprecation cycle of PEP-387.\r\n\r\nApart from the capsule C API issues, converting the remaining global variables to module state variables seem to be an easy task; most of them are used in either module functions or class methods. We can store the state in the `PyCursesWindow_Type` object for easy access and minimal churn.\r\n\r\n# Pitch\r\n\r\nThis is needed in order to support a per-interpreter GIL.\r\n\r\n# Previous discussion\r\n\r\nhttps://github.com/ericsnowcurrently/multi-core-python/wiki/0-The-Plan\r\n\r\n[^1]: `initialised_setupterm`, `initialisedcolors`, and `initialised`\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-104732\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/erlend-aasland","@type":"Person","name":"erlend-aasland"},"datePublished":"2023-02-08T22:42:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/101714/cpython/issues/101714"}
| 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:ea691b29-ef79-081d-9a52-563adc9acbe9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C140:22C7EF:F468FD:14738AA:69699227 |
| html-safe-nonce | 6215a99549686ed1dec04c4d6205163f8c51ad181ed949daa1a3c2358ae65c3b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTQwOjIyQzdFRjpGNDY4RkQ6MTQ3MzhBQTo2OTY5OTIyNyIsInZpc2l0b3JfaWQiOiIzODk1MDIyODUwODU3ODY1NzY3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 4656c45e8d9f0d87cbe636c6f4d8e0cab8dfb80e34cac2b45e97dde27162fcf3 |
| hovercard-subject-tag | issue:1576898134 |
| 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/101714/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e1bd4ce1fc01a0ca135b31bfa72f73fe0ec0d1ed7d2e56ef430ddeee971a1f2c/python/cpython/issues/101714 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e1bd4ce1fc01a0ca135b31bfa72f73fe0ec0d1ed7d2e56ef430ddeee971a1f2c/python/cpython/issues/101714 |
| og:image:alt | Feature or enhancement Isolate the _curses extension module. This means turning most global variables into module state variables. Globals in the _curses extension module: Name C type Notes PyCurse... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | erlend-aasland |
| 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