classification
Title: Incorrect documentation of the PyObject_HEAD macro
Type: behavior Stage:
Components: Documentation Versions: Python 3.3, Python 3.2, Python 3.1
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, trovao, ysj.ray
Priority: normal Keywords:

Created on 2010-06-16 19:58 by trovao, last changed 2010-11-25 06:07 by ysj.ray.

Messages (2)
msg107953 - (view) Author: Renato Cunha (trovao) Date: 2010-06-16 19:58
PyObject_HEAD's documentation in py3k (http://docs.python.org/dev/py3k/c-api/structures.html#PyObject_HEAD) uses the same content used in the python 2.x's docs which is wrong, as there were some API changes.

PyObject_HEAD is actually defined as

#define PyObject_HEAD PyObject ob_base;

with PyObject defined as

typedef struct _object {
    _PyObject_HEAD_EXTRA
    Py_ssize_t ob_refcnt;
    struct _typeobject *ob_type;
} PyObject;

(The PyTRACE_REFS discussion is still valid, though.)

Additionally, it'd be nice to mention that the Py_REFCNT(ob) and Py_TYPE(ob) macros should be used to access the PyObject members.
msg122333 - (view) Author: ysj.ray (ysj.ray) Date: 2010-11-25 06:07
Additionally, I prefer move the discussion of Py_TRACE_REFS under the documentation of PyObject: http://docs.python.org/dev/py3k/c-api/structures.html?highlight=pyobject_head#PyObject, since they'are connected directly. The doc of PyObject_HEAD should only saying like "expands to a PyObject variable".
History
Date User Action Args
2010-11-25 06:07:33ysj.raysetnosy: + ysj.ray
messages: + msg122333
2010-06-16 19:58:48trovaocreate