@@ -4,28 +4,32 @@ staticforward PyTypeObject noddy_NoddyType;
44
55typedef struct {
66 PyObject_HEAD
7+ /* Type-specific fields go here. */
78} noddy_NoddyObject ;
89
910static PyObject *
1011noddy_new_noddy (PyObject * self , PyObject * args )
1112{
1213 noddy_NoddyObject * noddy ;
1314
14- if (!PyArg_ParseTuple (args ,":new_noddy" ))
15- return NULL ;
16-
1715 noddy = PyObject_New (noddy_NoddyObject , & noddy_NoddyType );
1816
17+ /* Initialize type-specific fields here. */
18+
1919 return (PyObject * )noddy ;
2020}
2121
2222static void
2323noddy_noddy_dealloc (PyObject * self )
2424{
25+ /* Free any external resources here;
26+ * if the instance owns references to any Python
27+ * objects, call Py_DECREF() on them here.
28+ */
2529 PyObject_Del (self );
2630}
2731
28- static PyTypeObject noddy_NoddyType = {
32+ statichere PyTypeObject noddy_NoddyType = {
2933 PyObject_HEAD_INIT (NULL )
3034 0 ,
3135 "Noddy" ,
@@ -44,15 +48,19 @@ static PyTypeObject noddy_NoddyType = {
4448};
4549
4650static PyMethodDef noddy_methods [] = {
47- {"new_noddy" , noddy_new_noddy , METH_VARARGS ,
51+ {"new_noddy" , noddy_new_noddy , METH_NOARGS ,
4852 "Create a new Noddy object." },
49- {NULL , NULL , 0 , NULL }
53+
54+ {NULL } /* Sentinel */
5055};
5156
5257DL_EXPORT (void )
5358initnoddy (void )
5459{
5560 noddy_NoddyType .ob_type = & PyType_Type ;
61+ if (PyType_Ready (& noddy_NoddyType ))
62+ return ;
5663
57- Py_InitModule ("noddy" , noddy_methods );
64+ Py_InitModule3 ("noddy" , noddy_methods
65+ "Example module that creates an extension type." );
5866}
0 commit comments