Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-101714: Isolate _curses extension module#104732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Conversation
* converted `PyCursesWindowObject` to heap type * added module state containing previously global `PyCursesWindow_Type`, `PyCursesError` and `screen_encoding`; added `get__curses_state` and `find__curses_state_by_type` functions; changed functions and methods to access members of state or take state as a parameter * got rid of `ModDict` global variable, made functions/methods access it through `PyModule_GetDict` call; changed `SetDictInt` to accept dict as parameter * converted module to multi-phase init * changed signatures of functions used by C API in order to make exception stored in module state accessible by API users; reworked macros in Include/py_curses.h to reflect these changes * added `clinic_state()` macro for access to `PyCursesWindow_Type` in AC-generated code
…cref in _curses_exec
chgnrdv commented May 22, 2023
@erlend-aasland@kumaraditya303 |
* added `__reduce__` method to `_curses.window` type to make it non-pickable, as its static version was * added tests to check if `_curses.window` is non-instantiable/non-picklable/immutable * moved `SetDictInt` macro from function body * added NULL check for value returned by `PyCursesWindow_New` in `_curses_initscr_impl`
chgnrdv commented May 23, 2023
@erlend-aasland@kumaraditya303 for review. |
… slots for a while * removed excess newline characters
erlend-aasland commented Jun 2, 2023
I'm sorry, but I don't have the bandwidth to review this in the near future. |
chgnrdv commented Jun 2, 2023
@erlend-aasland, no problem, these aren't first priority changes anyway :) |
Uh oh!
There was an error while loading. Please reload this page.
Modules/_cursesmodule.c Outdated
| /*[clinic end generated code: output=da39a3ee5e6b4b0d input=83369be6e20ef0da]*/ | ||
| /* Tells whether setupterm() has been called to initialise terminfo. */ | ||
| static int initialised_setupterm = FALSE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These would also have to be moved to module state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Not sure if I did it the best way though.
chgnrdvJun 16, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure I didn't. At least exposing parts of _curses module state to C API in this way doesn't look safe for me.
…cr`/`start_color` funcs were called, to module state * removed funcs that were exposed to curses C API and used vars mentioned above * made C API use pointers to corresponding fields in curses state
erlend-aasland commented Jun 28, 2023
@chgnrdv: Sorry, but the linked issue has been closed as wont-fix. It is unfortunate given you spent a lot of time working on this. On the bright side: hopefully, you learnt a lot about the C API, extension modules and how to isolate them! Thank you for your interest in improving CPython. |
chgnrdv commented Jul 6, 2023
@erlend-aasland, no problem, I was ready for this as I read the conversation under original issue and knew that the need to isolate this module is debatable :)
Sure! Thank you for opportunity :) |
#101714
PyCursesWindowObjectto heap typePyCursesWindow_Type,PyCursesErrorandscreen_encoding; addedget__curses_stateandfind__curses_state_by_typefunctions; changed functions and methods to access members of state or take state as a parameterModDictglobal variable, made functions/methods access it throughPyModule_GetDictcall; changedSetDictIntto accept dict as parameterclinic_state()macro for access toPyCursesWindow_Typein AC-generated code