mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Patch #1537 from Chad Austin
Change GeneratorExit's base class from Exception to BaseException
This commit is contained in:
parent
6554cb94ba
commit
e69c320d48
7 changed files with 683 additions and 6 deletions
|
@ -1668,6 +1668,19 @@ And finalization:
|
|||
exiting
|
||||
|
||||
|
||||
GeneratorExit is not caught by except Exception:
|
||||
|
||||
>>> def f():
|
||||
... try: yield
|
||||
... except Exception: print 'except'
|
||||
... finally: print 'finally'
|
||||
|
||||
>>> g = f()
|
||||
>>> g.next()
|
||||
>>> del g
|
||||
finally
|
||||
|
||||
|
||||
Now let's try some ill-behaved generators:
|
||||
|
||||
>>> def f():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue