avoid some dead code in generator exit
authorStefan Behnel <stefan_ml@behnel.de>
Tue, 31 Dec 2013 12:40:42 +0000 (13:40 +0100)
committerStefan Behnel <stefan_ml@behnel.de>
Tue, 31 Dec 2013 12:40:42 +0000 (13:40 +0100)
Cython/Compiler/Nodes.py

index 1d934e87773cc10d240428cd8eb1e80f581f044b..856ebe90c9e6b3342d7f330e0b124cd1390308ad 100644 (file)
@@ -3849,10 +3849,12 @@ class GeneratorBodyDefNode(DefNode):
 
         # on normal generator termination, we do not take the exception propagation
         # path: no traceback info is required and not creating it is much faster
-        code.putln('PyErr_SetNone(PyExc_StopIteration);')
+        if not self.body.is_terminator:
+            code.putln('PyErr_SetNone(PyExc_StopIteration);')
         # ----- Error cleanup
         if code.error_label in code.labels_used:
-            code.put_goto(code.return_label)
+            if not self.body.is_terminator:
+                code.put_goto(code.return_label)
             code.put_label(code.error_label)
             for cname, type in code.funcstate.all_managed_temps():
                 code.put_xdecref(cname, type)