Issue 7853: on exit(), exc_value does not contain the exception. (original) (raw)

Created on 2010-02-04 09:35 by flox, last changed 2022-04-11 14:56 by admin. 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
2022-04-11 14:56:57 admin set github: 52101
2010-02-06 02:03:18 benjamin.peterson set messages: +
2010-02-05 02:12:53 benjamin.peterson set status: open -> closedresolution: fixedmessages: +
2010-02-05 00:40:14 flox set files: + issue7853_cm_exit.diffkeywords: + patchmessages: + stage: test needed -> patch review
2010-02-04 21:24:57 benjamin.peterson set assignee: benjamin.peterson
2010-02-04 12:52:28 pitrou set messages: +
2010-02-04 12:48:51 benjamin.peterson set messages: +
2010-02-04 12:47:07 pitrou set nosy: + pitrou, benjamin.petersonmessages: +
2010-02-04 09:37:57 flox set files: + case_contextmanager_exit.py
2010-02-04 09:37:49 flox set files: - case_contextmanager_exit.py
2010-02-04 09:35:08 flox create