On Thu, Jun 23, 2016 at 8:01 AM, Random832 <random...@fastmail.com> wrote:
> On Wed, Jun 22, 2016, at 11:11, Guido van Rossum wrote: > > This is done in order to force all mutations of the class dict to go > > through attribute assignments on the class. The latter takes care of > > updating the class struct, e.g. if you were to add an `__add__` method > > dynamically it would update tp_as_number->nb_add. If you could modify the > > dict object directly it would be more difficult to arrange for this side > > effect. > > Why is this different from the fact that updating a normal object's dict > bypasses descriptors and any special logic in __setattr__? Dunder > methods are already "special" in the sense that you can't use them as > object attributes; I wouldn't be surprised by "assigning a dunder method > via the class's dict breaks things". > It was a long time when I wrote this, but IIRC the breakage could express itself as a segfault or other C-level crash due to some internal state invariant of the type object being violated, not just an exception. The existence of ctypes notwithstanding, we take C-level crashes very seriously. -- --Guido van Rossum (python.org/~guido)
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com