[docs] [issue13705] Raising exceptions from finally works better than advertised in the documentation

Sinisa Segvic report at bugs.python.org
Tue Jan 3 23:13:08 CET 2012


New submission from Sinisa Segvic <sinisa.segvic at fer.hr>:

Hi,

The documentation says:
"""
If the finally clause raises another exception (...) the saved exception is lost. 
"""

This does not appear to be true. 
In the example below the backtrace shows both exceptions.

>>> import math
>>> try:
...   1/0
... finally:
...   math.sqrt(-1)
... 
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
ZeroDivisionError: division by zero

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
ValueError: math domain error

Cheers,

Siniša

----------
assignee: docs at python
components: Documentation
messages: 150544
nosy: docs at python, ssegvic
priority: normal
severity: normal
status: open
title: Raising exceptions from finally works better than advertised in the documentation
type: enhancement
versions: Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13705>
_______________________________________


More information about the docs mailing list