summaryrefslogtreecommitdiffstats
path: root/Doc/includes/noddy4.c
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/includes/noddy4.c')
-rw-r--r--Doc/includes/noddy4.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/Doc/includes/noddy4.c b/Doc/includes/noddy4.c
index ac0b1f4..94507ec 100644
--- a/Doc/includes/noddy4.c
+++ b/Doc/includes/noddy4.c
@@ -47,7 +47,7 @@ static void
Noddy_dealloc(Noddy* self)
{
Noddy_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -158,26 +158,27 @@ static PyMethodDef Noddy_methods[] = {
static PyTypeObject NoddyType = {
PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "noddy.Noddy", /*tp_name*/
- sizeof(Noddy), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Noddy_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+ "noddy.Noddy", /* tp_name */
+ sizeof(Noddy), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)Noddy_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT |
+ Py_TPFLAGS_BASETYPE |
+ Py_TPFLAGS_HAVE_GC, /* tp_flags */
"Noddy objects", /* tp_doc */
(traverseproc)Noddy_traverse, /* tp_traverse */
(inquiry)Noddy_clear, /* tp_clear */
@@ -198,26 +199,25 @@ static PyTypeObject NoddyType = {
Noddy_new, /* tp_new */
};
-static PyMethodDef module_methods[] = {
- {NULL} /* Sentinel */
+static PyModuleDef noddy4module = {
+ PyModuleDef_HEAD_INIT,
+ "noddy4",
+ "Example module that creates an extension type.",
+ -1,
+ NULL, NULL, NULL, NULL, NULL
};
-#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
-#define PyMODINIT_FUNC void
-#endif
PyMODINIT_FUNC
-initnoddy4(void)
+PyInit_noddy4(void)
{
PyObject* m;
if (PyType_Ready(&NoddyType) < 0)
- return;
-
- m = Py_InitModule3("noddy4", module_methods,
- "Example module that creates an extension type.");
+ return NULL;
+ m = PyModule_Create(&noddy4module);
if (m == NULL)
- return;
+ return NULL;
Py_INCREF(&NoddyType);
PyModule_AddObject(m, "Noddy", (PyObject *)&NoddyType);