classification
Title: on __exit__(), exc_value does not contain the exception.
Type: behavior Stage: patch review
Components: Interpreter Core Versions: Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: benjamin.peterson Nosy List: benjamin.peterson, flox, pitrou
Priority: high Keywords: patch

Created on 2010-02-04 09:35 by flox, last changed 2010-02-06 02:03 by benjamin.peterson. This issue is now closed.

Files
File name Uploaded Description Edit
case_contextmanager_exit.py flox, 2010-02-04 09:37
issue7853_cm_exit.diff flox, 2010-02-05 00:40 Patch, apply to trunk
Messages (7)
msg98817 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-02-04 09:35
On __exit__(), the 3rd argument "exc_value" should contain the instance of the exception.

But in most cases, it contains only the string representation of the exception.

See attached test case.
Same behavior for KeyError, AttributeError, RuntimeError, ...
msg98833 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-02-04 12:47
Indeed, it seems the exception isn't always normalized.
msg98834 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-02-04 12:48
Has this behavior changed between 2.6 and 2.7?
msg98835 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-02-04 12:52
No, it's also in 2.6.
msg98860 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-02-05 00:40
Patch.
msg98863 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-02-05 02:12
Fixed in r77983.
msg98928 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-02-06 02:03
BTW, I'm not going to backport this fix, since the implementation does carry over well to 2.6. Additionally, it is probably an unacceptable change of behavior in a bug fix release.
History
Date User Action Args
2010-02-06 02:03:18benjamin.petersonsetmessages: + msg98928
2010-02-05 02:12:53benjamin.petersonsetstatus: open -> closed
resolution: fixed
messages: + msg98863
2010-02-05 00:40:14floxsetfiles: + issue7853_cm_exit.diff
keywords: + patch
messages: + msg98860

stage: test needed -> patch review
2010-02-04 21:24:57benjamin.petersonsetassignee: benjamin.peterson
2010-02-04 12:52:28pitrousetmessages: + msg98835
2010-02-04 12:48:51benjamin.petersonsetmessages: + msg98834
2010-02-04 12:47:07pitrousetnosy: + pitrou, benjamin.peterson
messages: + msg98833
2010-02-04 09:37:57floxsetfiles: + case_contextmanager_exit.py
2010-02-04 09:37:49floxsetfiles: - case_contextmanager_exit.py
2010-02-04 09:35:08floxcreate