[New-bugs-announce] [issue10538] PyArg_ParseTuple("s*") does not always incref object
Kristján Valur Jónsson
report at bugs.python.org
Fri Nov 26 09:07:33 CET 2010
New submission from Kristján Valur Jónsson <kristjan at ccpgames.com>:
The new "s*" code for PyArg_ParseTuple is used to fill a Py_buffer object from the arguments. This object must be relased using PyBuffer_Release() after use.
However, if the object in the tuple does not support the new buffer interface, the old buffer interface is queried and the Py_buffer object is manually filled in. For this case, the source object is _not_ increfed and buffer.obj remains set to 0.
This causes different semantics in the function for objects that are passed in: If the Py_buffer interface is supported directly, then it is safe for the function to store this and release this at a later time. If it isn't supported, then no extra reference to the object is got and the function cannot safely keep the Py_buffer object around.
The Fix is as follows: Change line 1402 of getargs.c from:
PyBuffer_FillInfo(view, NULL, buf, count, 1, 0);
to
PyBuffer_FillInfo(view, arg, buf, count, 1, 0);
----------
messages: 122445
nosy: krisvale
priority: normal
severity: normal
status: open
title: PyArg_ParseTuple("s*") does not always incref object
type: behavior
versions: Python 2.7, Python 3.2
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10538>
_______________________________________
More information about the New-bugs-announce
mailing list