aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-evts.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python/py-evts.c')
-rw-r--r--gdb/python/py-evts.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/gdb/python/py-evts.c b/gdb/python/py-evts.c
index 644857d..1b78b82 100644
--- a/gdb/python/py-evts.c
+++ b/gdb/python/py-evts.c
@@ -20,6 +20,21 @@
#include "defs.h"
#include "py-events.h"
+#ifdef IS_PY3K
+static struct PyModuleDef EventModuleDef =
+{
+ PyModuleDef_HEAD_INIT,
+ "gdb.events",
+ NULL,
+ -1,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+#endif
+
/* Initialize python events. */
static int
@@ -45,7 +60,11 @@ add_new_registry (eventregistry_object **registryp, char *name)
void
gdbpy_initialize_py_events (void)
{
+#ifdef IS_PY3K
+ gdb_py_events.module = PyModule_Create (&EventModuleDef);
+#else
gdb_py_events.module = Py_InitModule ("events", NULL);
+#endif
if (!gdb_py_events.module)
goto fail;
@@ -62,7 +81,9 @@ gdbpy_initialize_py_events (void)
if (add_new_registry (&gdb_py_events.new_objfile, "new_objfile") < 0)
goto fail;
+#ifndef IS_PY3K
Py_INCREF (gdb_py_events.module);
+#endif
if (PyModule_AddObject (gdb_module,
"events",
(PyObject *) gdb_py_events.module) < 0)