Eryk Sun added the comment: Normally Python code calls built-in setattr, which calls the C API PyObject_SetAttr. This API interns the attribute name before calling the type's tp_setattro or tp_setattr function. Interning the string is a critical step, since the implementation for updating slots assumes the name is interned.
The __setattr__ slot wrapper calls wrap_setattr in Objects/typeobject.c. In line with how PyObject_SetAttr works, the attached patch interns the name in wrap_setattr before calling the wrapped setattrofunc. For good measure it also applies the same change to wrap_delattr, though that's not strictly necessary. ---------- keywords: +patch nosy: +eryksun versions: +Python 3.4, Python 3.5, Python 3.6 Added file: http://bugs.python.org/file41235/issue25794_1.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25794> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com