[pypy-svn] r73306 - in pypy/branch/cpython-extension/pypy/module/cpyext: include test
exarkun at codespeak.net
exarkun at codespeak.net
Fri Apr 2 21:05:23 CEST 2010
Author: exarkun
Date: Fri Apr 2 21:04:38 2010
New Revision: 73306
Added:
pypy/branch/cpython-extension/pypy/module/cpyext/test/modinit.c
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/include/modsupport.h
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py
Log:
Add a PyMODINIT_FUNC macro, plus a skipped test that fails for reasons probably unrelated to the implementation of PyMODINIT_FUNC
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/include/modsupport.h
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/include/modsupport.h (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/include/modsupport.h Fri Apr 2 21:04:38 2010
@@ -29,6 +29,10 @@
int PyModule_AddObject(PyObject *m, const char *name, PyObject *o);
+/*
+ * This is from pyport.h. Perhaps it belongs elsewhere.
+ */
+#define PyMODINIT_FUNC void
#ifdef __cplusplus
Added: pypy/branch/cpython-extension/pypy/module/cpyext/test/modinit.c
==============================================================================
--- (empty file)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/modinit.c Fri Apr 2 21:04:38 2010
@@ -0,0 +1,16 @@
+
+/*
+ * Trivial module which uses the PyMODINIT_FUNC macro.
+ */
+
+#include <Python.h>
+
+static PyMethodDef methods[] = {
+ { NULL }
+};
+
+PyMODINIT_FUNC
+initmodinit(void) {
+ Py_InitModule3("modinit", methods, "");
+}
+
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py Fri Apr 2 21:04:38 2010
@@ -245,6 +245,17 @@
assert module.__doc__ == "docstring"
assert module.return_cookie() == 3.14
+
+ def test_modinit_func(self):
+ """
+ A module can use the PyMODINIT_FUNC macro to declare or define its
+ module initializer function.
+ """
+ skip("This leaks references for some reason")
+ module = self.import_module(name='modinit')
+ assert module.__name__ == 'modinit'
+
+
def test_export_function2(self):
import sys
init = """
More information about the Pypy-commit
mailing list