[pypy-svn] r73169 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test

trundle at codespeak.net trundle at codespeak.net
Tue Mar 30 16:42:32 CEST 2010


Author: trundle
Date: Tue Mar 30 16:42:30 2010
New Revision: 73169

Added:
   pypy/branch/cpython-extension/pypy/module/cpyext/test/test_pyerrors.py
Modified:
   pypy/branch/cpython-extension/pypy/module/cpyext/pyerrors.py
Log:
Return exception type instead of value in PyErr_Occurred().

This makes test_intobject leak somehow.


Modified: pypy/branch/cpython-extension/pypy/module/cpyext/pyerrors.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/pyerrors.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/pyerrors.py	Tue Mar 30 16:42:30 2010
@@ -14,7 +14,7 @@
 def PyErr_Occurred(space):
     state = space.fromcache(State)
     register_container(space, lltype.nullptr(PyObject.TO))
-    return state.exc_value
+    return state.exc_type
 
 @cpython_api([], lltype.Void)
 def PyErr_Clear(space):

Added: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_pyerrors.py
==============================================================================
--- (empty file)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_pyerrors.py	Tue Mar 30 16:42:30 2010
@@ -0,0 +1,12 @@
+from pypy.module.cpyext.test.test_api import BaseApiTest
+from pypy.rpython.lltypesystem import rffi
+
+class TestExceptions(BaseApiTest):
+    def test_Occurred(self, space, api):
+        assert not api.PyErr_Occurred()
+        string = rffi.str2charp("spam and eggs")
+        api.PyErr_SetString(space.w_ValueError, string)
+        rffi.free_charp(string)
+        assert api.PyErr_Occurred() is space.w_ValueError
+
+        api.PyErr_Clear()



More information about the Pypy-commit mailing list