New submission from Stefan Behnel <[email protected]>:
Starting at line 1223 in classobject.c, you can find this code:
if (item == NULL)
arg = PyInt_FromSsize_t(i);
else
arg = Py_BuildValue("(nO)", i, item);
if (arg == NULL) {
Py_DECREF(func);
return -1;
}
res = PyEval_CallObject(func, arg);
If item is NULL, arg will be assigned an int object. Otherwise, it will receive
a tuple. Only the second case works in the subsequent call to
PyEval_CallObject(), i.e. arg must always be assigned an argument tuple.
A quick fix would be to call Py_BuildValue("(n)", i) in the first case. The
code just did a getattr(), so this is not performance critical anymore.
I found this bug because the test_class.py test suite was failing in Cython.
----------
components: Interpreter Core
messages: 145590
nosy: scoder
priority: normal
severity: normal
status: open
title: instance_ass_item() broken in classobject.c (Py2.7)
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue13186>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com