[pypy-svn] r75251 - in pypy/trunk/pypy/module/cpyext: . include

afa at codespeak.net afa at codespeak.net
Thu Jun 10 19:09:26 CEST 2010


Author: afa
Date: Thu Jun 10 19:09:21 2010
New Revision: 75251

Added:
   pypy/trunk/pypy/module/cpyext/include/modsupport.inl   (contents, props changed)
Modified:
   pypy/trunk/pypy/module/cpyext/include/Python.h
   pypy/trunk/pypy/module/cpyext/modsupport.py
Log:
Be sure to refuse extension modules built with CPython:
pypy-c does not define the Py_InitModule4 symbol anymore,
it exposes _Py_InitPyPyModule() instead,
and our Python.h takes care to redirect calls.

Next step: see if we can catch the error message and turn it into a friendly ImportError.


Modified: pypy/trunk/pypy/module/cpyext/include/Python.h
==============================================================================
--- pypy/trunk/pypy/module/cpyext/include/Python.h	(original)
+++ pypy/trunk/pypy/module/cpyext/include/Python.h	Thu Jun 10 19:09:21 2010
@@ -104,6 +104,8 @@
 
 #include <pypy_decl.h>
 
+#include "modsupport.inl"
+
 /* Define macros for inline documentation. */
 #define PyDoc_VAR(name) static char name[]
 #define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)

Added: pypy/trunk/pypy/module/cpyext/include/modsupport.inl
==============================================================================
--- (empty file)
+++ pypy/trunk/pypy/module/cpyext/include/modsupport.inl	Thu Jun 10 19:09:21 2010
@@ -0,0 +1,21 @@
+/* -*- C -*- */
+/* Module support interface */
+
+#ifndef Py_MODSUPPORT_INL
+#define Py_MODSUPPORT_INL
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+Py_LOCAL_INLINE(PyObject *) Py_InitModule4(
+        const char* name, PyMethodDef* methods,
+        const char* doc, PyObject *self,
+        int api_version)
+{
+        return _Py_InitPyPyModule(name, methods, doc, self, api_version);
+}
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_MODSUPPORT_INL */

Modified: pypy/trunk/pypy/module/cpyext/modsupport.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/modsupport.py	(original)
+++ pypy/trunk/pypy/module/cpyext/modsupport.py	Thu Jun 10 19:09:21 2010
@@ -31,9 +31,12 @@
 
     return w_mod
 
+# This is actually the Py_InitModule4 function,
+# renamed to refuse modules built against CPython headers.
+# The implementation of Py_InitModule4 is in include/modsupport.inl
 @cpython_api([CONST_STRING, lltype.Ptr(PyMethodDef), CONST_STRING,
               PyObject, rffi.INT_real], PyObject)
-def Py_InitModule4(space, name, methods, doc, w_self, apiver):
+def _Py_InitPyPyModule(space, name, methods, doc, w_self, apiver):
     """
     Create a new module object based on a name and table of functions, returning
     the new module object. If doc is non-NULL, it will be used to define the



More information about the Pypy-commit mailing list