Author: Maciej Fijalkowski <fij...@gmail.com>
Branch: 
Changeset: r67196:4852d98410ec
Date: 2013-10-08 11:30 +0200
http://bitbucket.org/pypy/pypy/changeset/4852d98410ec/

Log:    Merged in zyv/pypy (pull request #193)

        CPython C-API compat: PyErr_BadArgument() is of type int and always
        returns zero

diff --git a/pypy/module/cpyext/pyerrors.py b/pypy/module/cpyext/pyerrors.py
--- a/pypy/module/cpyext/pyerrors.py
+++ b/pypy/module/cpyext/pyerrors.py
@@ -103,11 +103,13 @@
     exc_p[0] = make_ref(space, operr.w_type)
     val_p[0] = make_ref(space, operr.get_w_value(space))
 
-@cpython_api([], lltype.Void)
+@cpython_api([], rffi.INT_real, error=0)
 def PyErr_BadArgument(space):
     """This is a shorthand for PyErr_SetString(PyExc_TypeError, message), where
     message indicates that a built-in operation was invoked with an illegal
-    argument.  It is mostly for internal use."""
+    argument.  It is mostly for internal use. In CPython this function always
+    raises an exception and returns 0 in all cases, hence the (ab)use of the
+    error indicator."""
     raise OperationError(space.w_TypeError,
             space.wrap("bad argument type for built-in operation"))
 
diff --git a/pypy/module/cpyext/test/test_pyerrors.py 
b/pypy/module/cpyext/test/test_pyerrors.py
--- a/pypy/module/cpyext/test/test_pyerrors.py
+++ b/pypy/module/cpyext/test/test_pyerrors.py
@@ -70,9 +70,10 @@
         api.PyErr_Clear()
 
     def test_BadArgument(self, space, api):
-        api.PyErr_BadArgument()
+        ret = api.PyErr_BadArgument()
         state = space.fromcache(State)
         assert space.eq_w(state.operror.w_type, space.w_TypeError)
+        assert ret == 0
         api.PyErr_Clear()
 
     def test_Warning(self, space, api, capfd):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to