Author: mattip <matti.pi...@gmail.com>
Branch: cpyext-ext
Changeset: r81937:26b7a0e96dc1
Date: 2016-01-17 08:17 +0200
http://bitbucket.org/pypy/pypy/changeset/26b7a0e96dc1/

Log:    test, fix - raise cpython compatible exception

diff --git a/pypy/module/cpyext/methodobject.py 
b/pypy/module/cpyext/methodobject.py
--- a/pypy/module/cpyext/methodobject.py
+++ b/pypy/module/cpyext/methodobject.py
@@ -276,7 +276,12 @@
 
 @cpython_api([PyObject], PyCFunction_typedef)
 def PyCFunction_GetFunction(space, w_obj):
-    cfunction = space.interp_w(W_PyCFunctionObject, w_obj)
+    try:
+        cfunction = space.interp_w(W_PyCFunctionObject, w_obj)
+    except OperationError, e:
+        if e.match(space, space.w_TypeError):
+            raise oefmt(space.w_SystemError, "bad argument to internal 
function")
+        raise
     return cfunction.ml.c_ml_meth
 
 @cpython_api([PyObject], PyObject)
diff --git a/pypy/module/cpyext/test/test_methodobject.py 
b/pypy/module/cpyext/test/test_methodobject.py
--- a/pypy/module/cpyext/test/test_methodobject.py
+++ b/pypy/module/cpyext/test/test_methodobject.py
@@ -90,7 +90,7 @@
         assert mod.isCFunction(mod.getarg_O) == "getarg_O"
         assert mod.getModule(mod.getarg_O) == 'MyModule'
         assert mod.isSameFunction(mod.getarg_O)
-        raises(TypeError, mod.isSameFunction, 1)
+        raises(SystemError, mod.isSameFunction, 1)
 
 class TestPyCMethodObject(BaseApiTest):
     def test_repr(self, space, api):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to