[issue31311] a SystemError and a crash in PyCData_setstate() when __dict__ is bad

Serhiy Storchaka report at bugs.python.org
Sun Sep 24 05:49:38 EDT 2017


Serhiy Storchaka added the comment:

I thought about this issue so long because I can't find good cause for __dict__ to be not a dict. Defining the __dict__ method or property doesn't affect instance dictionary and attributes lookup. It just breaks the __setstate__ method. Without having good example of overriding __dict__ I have no good test cases and don't know what a way of handling this error is better.

There is yet one disadvantage of the current implementation. The instance's dict can be lazy. It can be created only on demand, when instance's attribute is set or the __dict__ attribute is read. PyObject_GetAttrString(myself, "__dict__") creates it if it was not created. It would be more efficient to use _PyObject_GetDictPtr(). But this is a separate issue, 3.7 only.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31311>
_______________________________________


More information about the Python-bugs-list mailing list