[New-bugs-announce] [issue7608] PyUnicode_FromFormatV handles %R and %S incorrectly.
Alexandre Vassalotti
report at bugs.python.org
Thu Dec 31 00:16:54 CET 2009
New submission from Alexandre Vassalotti <alexandre at peadrop.com>:
It seems PyUnicode_FromFormatV wrongly assumes that the return value of
PyObject_Str and PyObject_Repr is a unicode object. It looks like the
%S and %R feature was backported from 3.x without updating the code for 2.x.
PyObject *
PyUnicode_FromFormatV(const char *format, va_list vargs)
{
...
case 'S':
{
PyObject *obj = va_arg(count, PyObject *);
PyObject *str;
assert(obj);
str = PyObject_Str(obj);
if (!str)
goto fail;
n += PyUnicode_GET_SIZE(str);
/* Remember the str and switch to the next slot */
*callresult++ = str;
break;
}
case 'R':
{
PyObject *obj = va_arg(count, PyObject *);
PyObject *repr;
assert(obj);
repr = PyObject_Repr(obj);
if (!repr)
goto fail;
n += PyUnicode_GET_SIZE(repr);
/* Remember the repr and switch to the next slot */
*callresult++ = repr;
break;
}
...
}
----------
components: Interpreter Core, Library (Lib)
messages: 97067
nosy: alexandre.vassalotti
severity: normal
stage: test needed
status: open
title: PyUnicode_FromFormatV handles %R and %S incorrectly.
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7608>
_______________________________________
More information about the New-bugs-announce
mailing list