[issue42418] PyType_GetModule() should warn/fail when type has Py_TPFLAGS_BASETYPE

2020-11-24 Thread Petr Viktorin
Petr Viktorin added the comment: > I missed it when I ported some of my code to heap types and multiphase init. I guess PyType_GetModule() is not good for that use case. If your code is open, could you add a link? -- ___ Python tracker

[issue42418] PyType_GetModule() should warn/fail when type has Py_TPFLAGS_BASETYPE

2020-11-21 Thread Petr Viktorin
Petr Viktorin added the comment: 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? A type and its subtypes may be defined in different modules; why would it be wrong to a

[issue42418] PyType_GetModule() should warn/fail when type has Py_TPFLAGS_BASETYPE

2020-11-20 Thread hai shi
hai shi added the comment: >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. +1. Looks like check Py_TPFLAGS_BASETYPE in PyType_GetModule() is an easy way:) -- nosy: +shihai1991

[issue42418] PyType_GetModule() should warn/fail when type has Py_TPFLAGS_BASETYPE

2020-11-20 Thread Christian Heimes
New submission from Christian Heimes : PyType_GetModule() may return wrong or unexpected result when a type has the feature flag Py_TPFLAGS_BASETYPE. The base type flag permits subclassing of an extension class. The function will return NULL when a type is subclasses in Python space or a diff