See the testcase below. If the body of the except clause is empty, 'e'
never gets assigned to the exception value, ie...

"""
>>> repr(e)
'ValueError()'
"""

e = None
try:
    raise ValueError
except ValueError, e:
    #a = 1
    pass

Could any of you fix this in order I can properly implement and test
"except A as B" ?? The fix should be done in "Nodes.py", at
"generate_handling_code()" ... The obvious patch is the one below, but
perhaps you can imagine a better way?

diff -r 3932a0be3b6b Cython/Compiler/Nodes.py
--- a/Cython/Compiler/Nodes.py  Thu Mar 11 18:57:06 2010 -0300
+++ b/Cython/Compiler/Nodes.py  Fri Mar 12 18:30:43 2010 -0300
@@ -4497,14 +4497,6 @@
         else:
             code.putln("/*except:*/ {")

-        if not getattr(self.body, 'stats', True):
-            # most simple case: no exception variable, empty body (pass)
-            # => reset the exception state, done
-            code.putln("PyErr_Restore(0,0,0);")
-            code.put_goto(end_label)
-            code.putln("}")
-            return
-
         exc_vars = [code.funcstate.allocate_temp(py_object_type,
                                                  manage_ref=True)
                     for i in xrange(3)]


PS: Is this an instance of "premature optimization is the root of all evil" ??

-- 
Lisandro Dalcin
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to