test case for exception propagation across functions
authorStefan Behnel <scoder@users.berlios.de>
Fri, 6 Jun 2008 06:31:11 +0000 (08:31 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 6 Jun 2008 06:31:11 +0000 (08:31 +0200)
tests/run/exceptionpropagation.pyx [new file with mode: 0644]

diff --git a/tests/run/exceptionpropagation.pyx b/tests/run/exceptionpropagation.pyx
new file mode 100644 (file)
index 0000000..e324a70
--- /dev/null
@@ -0,0 +1,17 @@
+__doc__ = u"""
+>>> foo(0)
+>>> foo(1)
+Traceback (most recent call last):
+RuntimeError
+"""
+
+cdef int CHKERR(int ierr) except -1:
+    if ierr==0: return 0
+    raise RuntimeError
+
+cdef int obj2int(object ob) except *:
+    return ob
+
+def foo(a):
+    cdef int i = obj2int(a)
+    CHKERR(i)