On 2/16/21 11:50 AM, Андрей Казанцев wrote:
It seems technically possible to override attributes/methods of built-in types, but the question is more if it's desirable?
The problem is that you cannot override the method not only in built-in types but also, for example, in `lxml.etree` classes. I wrote a module that changes the `type_setattro` method to mine, which does not have this check. And I'm wondering if there are any problems in this solution (in addition to philosophical ones) or everything will work as it should (and not as inheritance from built-in types). Thank you for participating in the discussion.
As with built-in types, lxml.etree classes and all other static (i.e. non-heap) types are shared between all interpreters in a process. Changing them has the same issues as with built-in types. The check for the Py_TPFLAGS_HEAPTYPE flag is correct.