[Python-Dev] Re: It is really necessary to check that a object has a Py_TPFLAGS_HEAPTYPE flag?

2021-02-16 Thread Kazantcev Andrey
Victor Stinner 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

[Python-Dev] It is really necessary to check that a object has a Py_TPFLAGS_HEAPTYPE flag?

2021-02-08 Thread Kazantcev Andrey
Hi everywhere. I decided to figure out why it is impossible to change methods of built-in types and found ``` if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) { PyErr_Format( PyExc_TypeError, "can't set attributes of built-in/extension type '%s'",