mirror of https://github.com/python/cpython
Patch #1537 from Chad Austin
Change GeneratorExit's base class from Exception to BaseException (This time I'm applying the patch to the correct sandbox.)
This commit is contained in:
parent
cbcfe4f3e4
commit
44eeaec173
|
@ -153,11 +153,13 @@ The following exceptions are the exceptions that are actually raised.
|
|||
.. 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
|
||||
|
||||
.. versionchanged:: 2.6
|
||||
Changed to inherit from :exc:`BaseException`.
|
||||
|
||||
.. exception:: IOError
|
||||
|
||||
|
|
|
@ -430,9 +430,6 @@ generator functions::
|
|||
... while True:
|
||||
... try:
|
||||
... value = (yield value)
|
||||
... except GeneratorExit:
|
||||
... # never catch GeneratorExit
|
||||
... raise
|
||||
... except Exception, e:
|
||||
... value = e
|
||||
... finally:
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
BaseException
|
||||
+-- SystemExit
|
||||
+-- KeyboardInterrupt
|
||||
+-- GeneratorExit
|
||||
+-- Exception
|
||||
+-- GeneratorExit
|
||||
+-- StopIteration
|
||||
+-- StandardError
|
||||
| +-- ArithmeticError
|
||||
|
@ -33,10 +33,10 @@ BaseException
|
|||
| +-- SystemError
|
||||
| +-- TypeError
|
||||
| +-- ValueError
|
||||
| | +-- UnicodeError
|
||||
| | +-- UnicodeDecodeError
|
||||
| | +-- UnicodeEncodeError
|
||||
| | +-- UnicodeTranslateError
|
||||
| +-- UnicodeError
|
||||
| +-- UnicodeDecodeError
|
||||
| +-- UnicodeEncodeError
|
||||
| +-- UnicodeTranslateError
|
||||
+-- Warning
|
||||
+-- DeprecationWarning
|
||||
+-- PendingDeprecationWarning
|
||||
|
|
|
@ -1658,6 +1658,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():
|
||||
|
|
|
@ -305,6 +305,8 @@ Core and builtins
|
|||
|
||||
- Bug #1664966: Fix crash in exec if Unicode filename can't be decoded.
|
||||
|
||||
- Issue #1537: Changed GeneratorExit's base class from Exception to BaseException.
|
||||
|
||||
Library
|
||||
-------
|
||||
|
||||
|
|
|
@ -437,9 +437,9 @@ SimpleExtendsException(PyExc_Exception, StopIteration,
|
|||
|
||||
|
||||
/*
|
||||
* GeneratorExit extends Exception
|
||||
* GeneratorExit extends BaseException
|
||||
*/
|
||||
SimpleExtendsException(PyExc_Exception, GeneratorExit,
|
||||
SimpleExtendsException(PyExc_BaseException, GeneratorExit,
|
||||
"Request that a generator exit.");
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue