summaryrefslogtreecommitdiff
path: root/Doc/extending
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2017-09-22 17:44:58 +0200
committerGitHub <noreply@github.com>2017-09-22 17:44:58 +0200
commitca72589bfabe2fd0e12eebfeb770b6c7a499b3e6 (patch)
treeed514225793ab4939a63bb04ba12228c2da419bc /Doc/extending
parent5e02c7826f9797fb3add79b608ef51f7a62b3e5a (diff)
downloadcpython-git-ca72589bfabe2fd0e12eebfeb770b6c7a499b3e6.tar.gz
bpo-31443: Formulate the type slot initialization rules in terms of C99. (#3688)
Diffstat (limited to 'Doc/extending')
-rw-r--r--Doc/extending/newtypes.rst13
1 files changed, 3 insertions, 10 deletions
diff --git a/Doc/extending/newtypes.rst b/Doc/extending/newtypes.rst
index f0e8985c61..0e36ba0aec 100644
--- a/Doc/extending/newtypes.rst
+++ b/Doc/extending/newtypes.rst
@@ -177,16 +177,9 @@ the module. We'll expand this example later to have more interesting behavior.
For now, all we want to be able to do is to create new :class:`Noddy` objects.
To enable object creation, we have to provide a :c:member:`~PyTypeObject.tp_new` implementation.
In this case, we can just use the default implementation provided by the API
-function :c:func:`PyType_GenericNew`. We'd like to just assign this to the
-:c:member:`~PyTypeObject.tp_new` slot, but we can't, for portability sake, On some platforms or
-compilers, we can't statically initialize a structure member with a function
-defined in another C module, so, instead, we'll assign the :c:member:`~PyTypeObject.tp_new` slot
-in the module initialization function just before calling
-:c:func:`PyType_Ready`::
-
- noddy_NoddyType.tp_new = PyType_GenericNew;
- if (PyType_Ready(&noddy_NoddyType) < 0)
- return;
+function :c:func:`PyType_GenericNew`. ::
+
+ PyType_GenericNew, /* tp_new */
All the other type methods are *NULL*, so we'll go over them later --- that's
for a later section!