summaryrefslogtreecommitdiffstats
path: root/Doc/extending
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-08-03 09:59:16 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2016-08-03 09:59:16 (GMT)
commit9f4712af259bf794ad0a9b055c991aa9d663eb9b (patch)
treeb9ccfa21c3b5941ff1965b1551afdc56e0b4c0c8 /Doc/extending
parent0d60c56e7e37cf7ef94ffd9591cf803351c33cfa (diff)
parentbed6891c7761888a2ea7b46c7b703c942e14091b (diff)
downloadcpython-9f4712af259bf794ad0a9b055c991aa9d663eb9b.zip
cpython-9f4712af259bf794ad0a9b055c991aa9d663eb9b.tar.gz
cpython-9f4712af259bf794ad0a9b055c991aa9d663eb9b.tar.bz2
Issue #23710: Merge from 3.5
Diffstat (limited to 'Doc/extending')
-rw-r--r--Doc/extending/newtypes.rst14
1 files changed, 9 insertions, 5 deletions
diff --git a/Doc/extending/newtypes.rst b/Doc/extending/newtypes.rst
index 5a207e6..a69f114 100644
--- a/Doc/extending/newtypes.rst
+++ b/Doc/extending/newtypes.rst
@@ -52,11 +52,15 @@ The first bit that will be new is::
} noddy_NoddyObject;
This is what a Noddy object will contain---in this case, nothing more than what
-every Python object contains---a refcount and a pointer to a type object.
-These are the fields the ``PyObject_HEAD`` macro brings in. The reason for the
-macro is to standardize the layout and to enable special debugging fields in
-debug builds. Note that there is no semicolon after the ``PyObject_HEAD``
-macro; one is included in the macro definition. Be wary of adding one by
+every Python object contains---a field called ``ob_base`` of type
+:c:type:`PyObject`. :c:type:`PyObject` in turn, contains an ``ob_refcnt``
+field and a pointer to a type object. These can be accessed using the macros
+:c:macro:`Py_REFCNT` and :c:macro:`Py_TYPE` respectively. These are the fields
+the :c:macro:`PyObject_HEAD` macro brings in. The reason for the macro is to
+standardize the layout and to enable special debugging fields in debug builds.
+
+Note that there is no semicolon after the :c:macro:`PyObject_HEAD` macro;
+one is included in the macro definition. Be wary of adding one by
accident; it's easy to do from habit, and your compiler might not complain,
but someone else's probably will! (On Windows, MSVC is known to call this an
error and refuse to compile the code.)