From: Dag Sverre Seljebotn Date: Wed, 14 May 2008 19:58:07 +0000 (+0200) Subject: Fixed iterator raising exception bug. X-Git-Tag: 0.9.8rc1~25 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=30d67e5aaa3bc6fc838733b26fccf3dc82f708ec;p=cython.git Fixed iterator raising exception bug. Simply a typo in NextNode... --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 2a95b4f2..47b94ba6 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -1197,7 +1197,7 @@ class NextNode(AtomicExprNode): code.putln( "if (!%s) {" % self.result_code) - code.error_goto_if_PyErr(self.pos) + code.putln(code.error_goto_if_PyErr(self.pos)) code.putln("break;") code.putln("}") code.putln("}") diff --git a/tests/run/iteratorexception.pyx b/tests/run/iteratorexception.pyx new file mode 100644 index 00000000..98f9806f --- /dev/null +++ b/tests/run/iteratorexception.pyx @@ -0,0 +1,17 @@ +__doc__ = """ + >>> f() +""" + +class IteratorAndIterateable: + def next(self): + raise ValueError("") + def __iter__(self): + return self + +def f(): + try: + for x in IteratorAndIterateable(): + pass + assert False, "Should not reach this point, iterator has thrown exception" + except ValueError: + pass