Index: Objects/exceptions.c =================================================================== --- Objects/exceptions.c (revision 59267) +++ Objects/exceptions.c (working copy) @@ -437,9 +437,9 @@ /* - * GeneratorExit extends Exception + * GeneratorExit extends BaseException */ -SimpleExtendsException(PyExc_Exception, GeneratorExit, +SimpleExtendsException(PyExc_BaseException, GeneratorExit, "Request that a generator exit."); Index: Doc/library/exceptions.rst =================================================================== --- Doc/library/exceptions.rst (revision 59267) +++ Doc/library/exceptions.rst (working copy) @@ -153,7 +153,7 @@ .. exception:: GeneratorExit Raise when a :term:`generator`\'s :meth:`close` method is called. It - directly inherits from :exc:`Exception` instead of :exc:`StandardError` since + directly inherits from :exc:`BaseException` instead of :exc:`StandardError` since it is technically not an error. .. versionadded:: 2.5 Index: Lib/test/test_generators.py =================================================================== --- Lib/test/test_generators.py (revision 59267) +++ Lib/test/test_generators.py (working copy) @@ -1658,6 +1658,19 @@ 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(): Index: Lib/test/exception_hierarchy.txt =================================================================== --- Lib/test/exception_hierarchy.txt (revision 59267) +++ Lib/test/exception_hierarchy.txt (working copy) @@ -1,8 +1,8 @@ BaseException +-- SystemExit +-- KeyboardInterrupt + +-- GeneratorExit +-- Exception - +-- GeneratorExit +-- StopIteration +-- StandardError | +-- ArithmeticError