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
PyType_GetModule() should warn/fail when type has Py_TPFLAGS_BASETYPE #86584
Comments
PyType_GetModule() may return wrong or unexpected result when a type has All subclassable types must use _PyType_GetModuleByDef() to safely access module and module state struct. It's easy to miss the problem. I missed it when I ported some of my code to heap types and multiphase init. I propose to either a guard to PyType_GetModule() to prevent misuse of the function or to add a variant of the function that prevents misuse. |
|
I don't understand this issue. Why would Py_TPFLAGS_BASETYPE make the result of PyType_GetModule() wrong? Is the note in the documentation of PyType_GetModule() not clear? Note that PyType_GetModule() is needed if users want to implement something like _PyType_GetModuleByDef(). |
I guess PyType_GetModule() is not good for that use case. |
I will close this issue. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: