[pypy-svn] r72448 - pypy/trunk/pypy/module/cpyext

xoraxax at codespeak.net xoraxax at codespeak.net
Sat Mar 20 14:35:21 CET 2010


Author: xoraxax
Date: Sat Mar 20 14:35:20 2010
New Revision: 72448

Modified:
   pypy/trunk/pypy/module/cpyext/methodobject.py
Log:
Issue an error message if from_ref fails here.

Modified: pypy/trunk/pypy/module/cpyext/methodobject.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/methodobject.py	(original)
+++ pypy/trunk/pypy/module/cpyext/methodobject.py	Sat Mar 20 14:35:20 2010
@@ -5,6 +5,8 @@
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.rpython.lltypesystem import rffi, lltype
 from pypy.module.cpyext.api import PyObject, from_ref
+from pypy.rlib.objectmodel import we_are_translated
+
 
 class W_PyCFunctionObject(Wrappable):
     def __init__(self, ml, w_self, w_modname):
@@ -20,7 +22,15 @@
 
     # Call the C function
     result = self.ml.c_ml_meth(null, null)
-    ret = from_ref(space, result)
+    try:
+        ret = from_ref(space, result)
+    except RuntimeError:
+        if not we_are_translated():
+            import sys
+            print >>sys.stderr, "Calling a function failed. Did it" \
+                    " really return an PyObject?"
+        raise
+
     # XXX result.decref()
     return ret
 



More information about the Pypy-commit mailing list