[Python-Dev] PyObject_IsInstance is dangerous (original) (raw)
Serhiy Storchaka storchaka at gmail.com
Mon May 18 14:34:15 CEST 2015
- Previous message (by thread): [Python-Dev] PyObject_IsInstance is dangerous
- Next message (by thread): [Python-Dev] PyObject_IsInstance is dangerous
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 18.05.15 15:14, Greg Ewing wrote:
Serhiy Storchaka wrote:
PyObjectIsInstance is not safe when used to check if the object is an instance of specified builtin type.
The class attribute can be modified and PyObjectIsInstance() can return true if the object has not layout compatible with specified structure. Code that requires a particular C layout should be using PyObjectTypeCheck, not PyObjectIsInstance.
Thank you. I didn't know about this helper.
Looks as most (if not all) usages of PyObject_IsInstance are not correct. May be modify PyObject_IsInstance so that it will never return true if layouts are not compatible?
- Previous message (by thread): [Python-Dev] PyObject_IsInstance is dangerous
- Next message (by thread): [Python-Dev] PyObject_IsInstance is dangerous
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]