
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2008-06-01 20:03 bypitrou, last changed2022-04-11 14:56 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| exc_stacking.patch | pitrou,2008-06-01 20:03 | |||
| finally.patch | pitrou,2008-06-07 20:58 | |||
| Messages (10) | |||
|---|---|---|---|
| msg67598 -(view) | Author: Antoine Pitrou (pitrou)*![]() | Date: 2008-06-01 20:03 | |
This patch implements the proposal outlined on the py3k mailing-listhere:http://mail.python.org/pipermail/python-3000/2008-May/013740.htmlIt solves both#2507 and#2833, and even improves re-raising semanticsin several cases (see the test cases which were added to test_raise.py).Anothing thing worth noting is that f_exc_* fields are not accessiblefrom Python code anymore, because their semantics is an implementationdetail and shouldn't be relied upon. | |||
| msg67782 -(view) | Author: Adam Olsen (Rhamphoryncus) | Date: 2008-06-06 20:09 | |
PEP 3134's implicit exception chaining (if accepted) would require yoursemantic, and your semantic is simpler anyway (even if theimplementation is non-trivial), so consider my objections to be dropped.PEP 3134 also proposes implicit chaining during a finally block, whichraises questions for this case:try: ...finally: print(sys.exc_info()) raiseIf sys.exc_info() were removed (with no direct replacement) we'd havethat behaviour answered. raise could be answered by making it a syntaxerror, but keep in mind this may be nested in another except block:try: ...except: try: ... finally: raiseI'd prefer a syntax error in this case as well, to avoid any ambiguityand to keep the implementation simple. | |||
| msg67789 -(view) | Author: Antoine Pitrou (pitrou)*![]() | Date: 2008-06-06 21:54 | |
With or without my patch, bare "raise" inside a "finally" statementraises a "RuntimeError: no active exception to re-raise". (except, ofcourse, when the try/finally is itself enclosed in an except block)That's because a finally block is not considered an exception handler. Idon't think there's any reason to change this.I'm not for adding syntax errors. After all the bare "raise" statementjust does the moral equivalent of re-raising sys.exc_info() verbatim. Inthose situations where sys.exc_info() would return a non-empty result,why shouldn't "raise" be accepted as well? | |||
| msg67790 -(view) | Author: Antoine Pitrou (pitrou)*![]() | Date: 2008-06-06 22:30 | |
(an unexpected side effect of my patch is that the interpreter hasbecome 5-10% faster under Linux, witnessed with pystone and pybench. Idon't know the explanation) | |||
| msg67795 -(view) | Author: Adam Olsen (Rhamphoryncus) | Date: 2008-06-07 02:25 | |
PEP 3134 gives reason to change it. __context__ should be set fromwhatever exception is "active" from the try/finally, thus it should bethe inner block, not the outer except block.This flipping of behaviour, and the general ambiguity, is why I suggesta syntax error. "In the face of ambiguity, refuse the temptation to guess."PEP 3134 has not been officially accepted, but many parts have be addedanyway. Your cleanups pave the way for the last of it. I suggestasking on python-3000 for a pronouncement on the PEP. | |||
| msg67800 -(view) | Author: Antoine Pitrou (pitrou)*![]() | Date: 2008-06-07 05:33 | |
Ok, it makes sense to have the same behaviour for except and finallyblocks then. As for the syntax error, I'm still not convinced. The pointof Py3k is to change semantics: people should expect some incompatiblechanges. Also the previous behaviour was rather under-specified, so itcould be considered a bug. And it seems to me syntax errors should beused to guard against potential syntax mistakes, not semantic subtleties. | |||
| msg67801 -(view) | Author: Adam Olsen (Rhamphoryncus) | Date: 2008-06-07 06:37 | |
I agree, the argument for a syntax error is weak. It's more instinctthan anything else. I don't think I'd be able to convince you unlessGuido had the same instinct I do. ;) | |||
| msg67816 -(view) | Author: Antoine Pitrou (pitrou)*![]() | Date: 2008-06-07 20:58 | |
Here is a newer patch that also adapts the behaviour of finally blocksas suggested by Adam Olsen. Note that I had to change some things in theway 'with' statements are compiled and executed. | |||
| msg67938 -(view) | Author: Benjamin Peterson (benjamin.peterson)*![]() | Date: 2008-06-11 03:12 | |
Guido has given the go ahead on this. I will apply in about 8 hours(after some sleep). | |||
| msg67989 -(view) | Author: Benjamin Peterson (benjamin.peterson)*![]() | Date: 2008-06-11 16:00 | |
Commited inr64121. | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:35 | admin | set | github: 47271 |
| 2008-06-11 16:00:24 | benjamin.peterson | set | status: open -> closed messages: +msg67989 |
| 2008-06-11 03:12:19 | benjamin.peterson | set | assignee:benjamin.peterson resolution: accepted messages: +msg67938 |
| 2008-06-07 20:58:31 | pitrou | set | files: +finally.patch messages: +msg67816 |
| 2008-06-07 06:37:39 | Rhamphoryncus | set | messages: +msg67801 |
| 2008-06-07 05:33:46 | pitrou | set | messages: +msg67800 |
| 2008-06-07 02:25:54 | Rhamphoryncus | set | messages: +msg67795 |
| 2008-06-06 22:30:40 | pitrou | set | messages: +msg67790 |
| 2008-06-06 21:54:08 | pitrou | set | messages: +msg67789 |
| 2008-06-06 20:10:02 | Rhamphoryncus | set | messages: +msg67782 |
| 2008-06-02 07:32:08 | Rhamphoryncus | set | nosy: +Rhamphoryncus |
| 2008-06-01 21:33:40 | benjamin.peterson | set | nosy: +benjamin.peterson |
| 2008-06-01 21:33:14 | benjamin.peterson | link | issue2833 superseder |
| 2008-06-01 21:33:06 | benjamin.peterson | link | issue2507 superseder |
| 2008-06-01 20:03:45 | pitrou | create | |