[pypy-issue] [issue1122] [cpyext] PyVarObject builtins and definition of Py_SIZE()
Amaury Forgeot d Arc
tracker at bugs.pypy.org
Tue Apr 10 23:12:08 CEST 2012
Amaury Forgeot d Arc <amauryfa at gmail.com> added the comment:
Duplicating the size field would work for immutable (or non-resizeable) objects, but not for lists or dicts:
the storage is maintained outside the C structure.
A possible fix is to use tp_itemsize to determine if the object has an ob_size:
#define Py_SIZE(obj) \
(obj)->ob_type->tp_itemsize ? ((PyVarObject*)(obj))->ob_size : PyObject_Size(obj)
And then, turn tuple and strings into PyVarObjects.
status: unread -> chatting
PyPy bug tracker <tracker at bugs.pypy.org>
More information about the pypy-issue