[ python-Bugs-950057 ] itertools.chain doesn't "process" exceptions
as they occur
SourceForge.net
noreply at sourceforge.net
Fri May 7 14:34:48 EDT 2004
Bugs item #950057, was opened at 2004-05-07 20:32
Message generated for change (Comment added) made by mithrandi
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=950057&group_id=5470
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Tristan Seligmann (mithrandi)
>Assigned to: Raymond Hettinger (rhettinger)
Summary: itertools.chain doesn't "process" exceptions as they occur
Initial Comment:
Python 2.3.3 (#2, Feb 24 2004, 09:29:20)
[GCC 3.3.3 (Debian)] on linux2
The following code demonstrates the problem:
import itertools
def gen1():
print 'Before yield 1'
yield 1
print 'After yield 1'
assert False
def gen2(x = False):
print 'Before yield 2'
yield 2
print 'After yield 2'
if x:
raise StopIteration
for elem in itertools.chain(gen1(), gen2()):
print elem
The exception only propagates up after itertools.chain
completes iteration; if you pass True to gen2(), then
the AssertionError will be completely masked,
concealing the fact that any exception has been raised.
----------------------------------------------------------------------
>Comment By: Tristan Seligmann (mithrandi)
Date: 2004-05-07 20:34
Message:
Logged In: YES
user_id=557968
Oops, providing example code as an attachment this time instead.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=950057&group_id=5470
More information about the Python-bugs-list
mailing list