Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raising exceptions from finally works better than advertised in the documentation #57914

Closed
ssegvic mannequin opened this issue Jan 3, 2012 · 3 comments
Closed

Raising exceptions from finally works better than advertised in the documentation #57914

ssegvic mannequin opened this issue Jan 3, 2012 · 3 comments
Labels
docs Documentation in the Doc dir type-feature A feature request or enhancement

Comments

@ssegvic
Copy link
Mannequin

ssegvic mannequin commented Jan 3, 2012

BPO 13705

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2012-01-03.22:31:00.401>
created_at = <Date 2012-01-03.22:13:08.206>
labels = ['type-feature', 'docs']
title = 'Raising exceptions from finally works better than advertised in the documentation'
updated_at = <Date 2012-01-03.22:31:00.400>
user = 'https://bugs.python.org/ssegvic'

bugs.python.org fields:

activity = <Date 2012-01-03.22:31:00.400>
actor = 'python-dev'
assignee = 'docs@python'
closed = True
closed_date = <Date 2012-01-03.22:31:00.401>
closer = 'python-dev'
components = ['Documentation']
creation = <Date 2012-01-03.22:13:08.206>
creator = 'ssegvic'
dependencies = []
files = []
hgrepos = []
issue_num = 13705
keywords = []
message_count = 3.0
messages = ['150544', '150546', '150547']
nosy_count = 3.0
nosy_names = ['docs@python', 'python-dev', 'ssegvic']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue13705'
versions = ['Python 3.2']

@ssegvic
Copy link
Mannequin Author

ssegvic mannequin commented Jan 3, 2012

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

@ssegvic ssegvic mannequin assigned docspython Jan 3, 2012
@ssegvic ssegvic mannequin added docs Documentation in the Doc dir type-feature A feature request or enhancement labels Jan 3, 2012
@ssegvic
Copy link
Mannequin Author

ssegvic mannequin commented Jan 3, 2012

Link to the documentation:
http://docs.python.org/py3k/reference/compound_stmts.html#id2

@python-dev
Copy link
Mannequin

python-dev mannequin commented Jan 3, 2012

New changeset c39fbb24b3f4 by Benjamin Peterson in branch '3.2':
exception support is correct now (closes bpo-13705)
http://hg.python.org/cpython/rev/c39fbb24b3f4

@python-dev python-dev mannequin closed this as completed Jan 3, 2012
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

0 participants