On 8/27/2013 3:52 PM, Marco Buttu wrote:
On 08/27/2013 08:51 PM, Terry Reedy wrote:
BaseException was added just so it would be possible to catch nearly
everything but a few exceptions. The first two were KeyboardInterrupt
and SystemExit (in 2.5). GeneratorExit was switched in 2.6, but I forget
the details of why.
Maybe in order to don't catch it inside a generator using a except
Exception clause, because it is used to notify an active generator is
closed:
>>> def foogen():
... for i in range(10):
... try:
... yield i
... except:
... print('Catched!')
... # raise
...
>>> g = foogen()
>>> next(g)
0
>>> g.close()
Catched!
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: generator ignored GeneratorExit
Do you remember if this is the reason? Thanks,
I only remember that there was a 'problem' that necessitated a change in
2.6 after the introduction in 2.5. The above seems reasonable.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list