Include implementation experience.
This commit is contained in:
parent
cef6e8f06a
commit
51a225ee53
20
pep-3123.txt
20
pep-3123.txt
|
@ -106,11 +106,13 @@ As a convention, the base field SHOULD be called ob_base. However, all
|
||||||
accesses to ob_refcnt and ob_type MUST cast the object pointer to
|
accesses to ob_refcnt and ob_type MUST cast the object pointer to
|
||||||
PyObject* (unless the pointer is already known to have that type), and
|
PyObject* (unless the pointer is already known to have that type), and
|
||||||
SHOULD use the respective accessor macros. To simplify access to
|
SHOULD use the respective accessor macros. To simplify access to
|
||||||
ob_type, a macro::
|
ob_type, ob_refcnt, and ob_size, macros::
|
||||||
|
|
||||||
#define Py_Type(o) (((PyObject*)o)->ob_type)
|
#define Py_Type(o) (((PyObject*)(o))->ob_type)
|
||||||
|
#define Py_Refcnt(o) (((PyObject*)(o))->ob_refcnt)
|
||||||
|
#define Py_Size(o) (((PyVarObject*)(o))->ob_size)
|
||||||
|
|
||||||
is added. E.g. the code blocks::
|
are added. E.g. the code blocks::
|
||||||
|
|
||||||
#define PyList_CheckExact(op) ((op)->ob_type == &PyList_Type)
|
#define PyList_CheckExact(op) ((op)->ob_type == &PyList_Type)
|
||||||
|
|
||||||
|
@ -121,13 +123,21 @@ needs to be changed to::
|
||||||
#define PyList_CheckExact(op) (Py_Type(op) == &PyList_Type)
|
#define PyList_CheckExact(op) (Py_Type(op) == &PyList_Type)
|
||||||
|
|
||||||
return Py_Type(func)->tp_name;
|
return Py_Type(func)->tp_name;
|
||||||
|
|
||||||
|
For initialization of type objects, the current sequence::
|
||||||
|
|
||||||
|
PyObject_HEAD_INIT(NULL)
|
||||||
|
0, /* ob_size */
|
||||||
|
|
||||||
|
becomes incorrect, and must be replaced with
|
||||||
|
|
||||||
|
PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
|
|
||||||
Compatibility with Python 2.6
|
Compatibility with Python 2.6
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
To support modules that compile with both Python 2.6 and Python 3.0,
|
To support modules that compile with both Python 2.6 and Python 3.0,
|
||||||
the Py_Type macro is added to Python 2.6. The macros Py_INCREF
|
the Py_* macros is added to Python 2.6. The macros Py_INCREF
|
||||||
and Py_DECREF will be changed to cast their argument to PyObject\*,
|
and Py_DECREF will be changed to cast their argument to PyObject\*,
|
||||||
so that module authors can also explicitly declare the ob_base
|
so that module authors can also explicitly declare the ob_base
|
||||||
field in modules designed for Python 2.6.
|
field in modules designed for Python 2.6.
|
||||||
|
|
Loading…
Reference in New Issue