[pypy-svn] r73175 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test
afa at codespeak.net
afa at codespeak.net
Tue Mar 30 17:11:23 CEST 2010
Author: afa
Date: Tue Mar 30 17:11:22 2010
New Revision: 73175
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/state.py
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_pyerrors.py
Log:
Correctly borrow exc_type with PyErr_Occurred()
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/state.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/state.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/state.py Tue Mar 30 17:11:22 2010
@@ -30,10 +30,10 @@
from pypy.module.cpyext.api import make_ref, ADDR
# handling of borrowed objects, remove when we have
# a weakkeydict
- exc_value = make_ref(self.space, self.exc_value, borrowed=True)
- if exc_value:
- Py_DECREF(self.space, exc_value)
- containee_ptr = rffi.cast(ADDR, exc_value)
+ exc_type = make_ref(self.space, self.exc_type, borrowed=True)
+ if exc_type:
+ Py_DECREF(self.space, exc_type)
+ containee_ptr = rffi.cast(ADDR, exc_type)
del self.borrowed_objects[containee_ptr]
self.exc_type = None
self.exc_value = None
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_pyerrors.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_pyerrors.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_pyerrors.py Tue Mar 30 17:11:22 2010
@@ -1,4 +1,5 @@
from pypy.module.cpyext.test.test_api import BaseApiTest
+from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
from pypy.rpython.lltypesystem import rffi
class TestExceptions(BaseApiTest):
@@ -10,3 +11,17 @@
assert api.PyErr_Occurred() is space.w_ValueError
api.PyErr_Clear()
+
+class AppTestFetch(AppTestCpythonExtensionBase):
+ def test_occurred(self):
+ module = self.import_extension('foo', [
+ ("check_error", "METH_NOARGS",
+ '''
+ PyErr_SetString(PyExc_TypeError, "message");
+ PyErr_Occurred();
+ PyErr_Clear();
+ Py_RETURN_TRUE;
+ '''
+ ),
+ ])
+ module.check_error()
More information about the Pypy-commit
mailing list