[PATCH 2 of 2] inotify extension: Port of the C module to py3k
Renato Cunha
renatoc at gmail.com
Thu Jun 17 17:51:54 CDT 2010
hgext/inotify/linux/_inotify.c | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)
# HG changeset patch
# User Renato Cunha <renatoc at gmail.com>
# Date 1276814950 10800
# Node ID 6ab9526babace0ab8b5c5ab1dec5e75bb3d68462
# Parent bd9094ef035b3635b66b8334e78648f809fceacb
inotify extension: Port of the C module to py3k.
This patch accomplishes the port of the inotify C module to py3k by #including
mercurial's util.h file, and by defining the necessary boilerplate code
required by py3k through conditional compilation.
diff --git a/hgext/inotify/linux/_inotify.c b/hgext/inotify/linux/_inotify.c
--- a/hgext/inotify/linux/_inotify.c
+++ b/hgext/inotify/linux/_inotify.c
@@ -15,6 +15,8 @@
#include <sys/ioctl.h>
#include <unistd.h>
+#include <util.h>
+
static PyObject *init(PyObject *self, PyObject *args)
{
PyObject *ret = NULL;
@@ -393,8 +395,7 @@
}
static PyTypeObject event_type = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_inotify.event", /*tp_name*/
sizeof(struct event), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -588,6 +589,32 @@
{NULL},
};
+#ifdef IS_PY3K
+static struct PyModuleDef _inotify_module = {
+ PyModuleDef_HEAD_INIT,
+ "_inotify",
+ doc,
+ -1,
+ methods
+};
+
+PyMODINIT_FUNC PyInit__inotify(void)
+{
+ PyObject *mod, *dict;
+
+ mod = PyModule_Create(&_inotify_module);
+
+ if (mod == NULL)
+ return NULL;
+
+ dict = PyModule_GetDict(mod);
+
+ if (dict)
+ define_consts(dict);
+
+ return mod;
+}
+#else
void init_inotify(void)
{
PyObject *mod, *dict;
@@ -602,3 +629,4 @@
if (dict)
define_consts(dict);
}
+#endif
More information about the Mercurial-devel
mailing list