[pypy-svn] r73612 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test
jandem at codespeak.net
jandem at codespeak.net
Sat Apr 10 14:01:47 CEST 2010
Author: jandem
Date: Sat Apr 10 14:01:46 2010
New Revision: 73612
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/object.py
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py
Log:
Test PyObject_RichCompare with invalid opid
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/object.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/object.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/object.py Sat Apr 10 14:01:46 2010
@@ -6,7 +6,7 @@
from pypy.module.cpyext.pyobject import Py_IncRef, Py_DecRef
from pypy.module.cpyext.state import State
from pypy.module.cpyext.typeobject import PyTypeObjectPtr, W_PyCTypeObject
-from pypy.module.cpyext.pyerrors import PyErr_NoMemory
+from pypy.module.cpyext.pyerrors import PyErr_NoMemory, PyErr_BadInternalCall
from pypy.objspace.std.objectobject import W_ObjectObject
from pypy.objspace.std.typeobject import W_TypeObject
import pypy.module.__builtin__.operation as operation
@@ -140,4 +140,4 @@
Python expression o1 op o2, where op is the operator corresponding to
opid."""
w_res = PyObject_RichCompare(space, ref1, ref2, opid)
- return PyObject_IsTrue(space, w_res)
+ return int(space.is_true(w_res))
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py Sat Apr 10 14:01:46 2010
@@ -89,3 +89,8 @@
test_compare(1, 2)
test_compare(2, 2)
test_compare('2', '1')
+
+ w_i = space.wrap(1)
+ assert api.PyObject_RichCompareBool(w_i, w_i, 123456) == -1
+ assert api.PyErr_Occurred() is space.w_SystemError
+ api.PyErr_Clear()
More information about the Pypy-commit
mailing list