This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: instance_ass_item() broken in classobject.c (Py2.7)
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: python-dev, scoder
Priority: normal Keywords:

Created on 2011-10-15 13:30 by scoder, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg145590 - (view) Author: Stefan Behnel (scoder) * (Python committer) Date: 2011-10-15 13:30
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.
msg145602 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-10-15 17:43
New changeset 418fbf1af875 by Benjamin Peterson in branch '2.7':
PyEval_CallObject requires a tuple of args (closes #13186)
http://hg.python.org/cpython/rev/418fbf1af875
History
Date User Action Args
2022-04-11 14:57:22adminsetgithub: 57395
2011-10-15 17:43:33python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg145602

resolution: fixed
stage: resolved
2011-10-15 13:30:37scodercreate