[New-bugs-announce] [issue24257] Incorrect use of PyObject_IsInstance

Serhiy Storchaka report at bugs.python.org
Thu May 21 10:40:46 CEST 2015


New submission from Serhiy Storchaka:

PyObject_IsInstance() is used incorrectly for testing if Python object is an instance of specified builtin type before direct access to internals of object. This is not correct, because PyObject_IsInstance() checks the __class__ attribute that can be modified and even can be dynamic property. Correct way is to check static type. Proposed patch replaces PyObject_IsInstance() with PyObject_TypeCheck() if this is appropriate.

See also similar issues issue24102 and issue24091.

----------
components: Extension Modules, Interpreter Core
files: typecheck.patch
keywords: patch
messages: 243739
nosy: serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Incorrect use of PyObject_IsInstance
type: crash
versions: Python 2.7, Python 3.4, Python 3.5
Added file: http://bugs.python.org/file39450/typecheck.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24257>
_______________________________________


More information about the New-bugs-announce mailing list