Stefan Behnel wrote:
> Lisandro Dalcin wrote:
>> GCC complains about uninitialized variables when compiling the
>> generated C sources in some cases like the below:
>>
>> 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)
>
> I added that as test case under tests/run/exceptionpropagation.pyx.
The following works for me (it's in cython-devel).
Stefan
# HG changeset patch
# User Stefan Behnel <[EMAIL PROTECTED]>
# Date 1212765117 -7200
# Node ID 7a3fa433aaf4da1c2e2f655facd8889658820e8c
# Parent e92098251a9d38ef700c78bfb6ed593f685ba563
fix return value setting for 'except *' functions
diff -r e92098251a9d -r 7a3fa433aaf4 Cython/Compiler/Nodes.py
--- a/Cython/Compiler/Nodes.py Fri Jun 06 08:31:11 2008 +0200
+++ b/Cython/Compiler/Nodes.py Fri Jun 06 17:11:57 2008 +0200
@@ -956,6 +956,8 @@ class FuncDefNode(StatNode, BlockNode):
exc_check = self.caller_will_check_exceptions()
if err_val is not None or exc_check:
code.putln('__Pyx_AddTraceback("%s");' %
self.entry.qualified_name)
+ if err_val is None and self.return_type.default_value:
+ err_val = self.return_type.default_value
if err_val is not None:
code.putln(
"%s = %s;" % (
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev