bpo-37830: Revert "bpo-32489: Allow 'continue' in 'finally' clause. (GH-5822)"#15230
bpo-37830: Revert "bpo-32489: Allow 'continue' in 'finally' clause. (GH-5822)"#15230serhiy-storchaka wants to merge 2 commits into
Conversation
…ythonGH-5822)" This reverts commit fe2bbb1.
|
We should also inform @ambv so it removes this from the main announcement of future releases. |
Sorry, something went wrong.
|
FWIW I think that @ncoghlan FYI we did discuss this topic at PyCon AU 2018 |
Sorry, something went wrong.
|
Actually this reversion does not solve the issue completely: https://bugs.python.org/issue37830#msg349513. So it does not make sense to do it. |
Sorry, something went wrong.
|
The rationale of making life easier for interpreter implementors still applies though - the fact that try/finally can be used to suppress an exception is genuinely weird. |
Sorry, something went wrong.
vstinner
left a comment
There was a problem hiding this comment.
LGTM. I'm ok to revert the change in Python 3.8 to get more time to find maybe a different approach in Python 3.9. Right now, we have to focus on stabilizing Python 3.8.
Sorry, something went wrong.
|
I have closed this issue because I do not see any sense in reverting changes for |
Sorry, something went wrong.
|
@serhiy-storchaka The request from MicroPython was to reconsider allowing this construct at all. The fact that break is broken in the same way is a solid argument that we should stop digging the hole deeper (and perhaps consider disallowing break as well). We're making work for other implementations for no good reason. |
Sorry, something went wrong.
Probably here is not the right place to have such a discussion, but my aim was to raise the point that we also had issues with return/break/continue in a finally, and that I would support changing the language to disallow this combination of constructs. return/break/continue in a finally suite will (silently) cancel any raised exception, which is unexpected behaviour and probably not what the writer of the Python code intended. At least there are other ways to write such code (without having return/break/continue in the finally) which has more explicit behaviour. I did a survey of the Python standard library and this pattern is rarely used. And where it is used it's easy to change it. I would consider writing a PEP to disallow this construct, if there's interest. |
Sorry, something went wrong.
|
@isidentical @dpgeorge A draft PEP for that would be a good next step. I'd be happy to take on the PEP sponsor role. For continue, the proposal would be to not add support in Python 3.8, while for return and break, the proposal would be to deprecate in 3.9, emit a compilation warning in 3.10, and then disallow after that. |
Sorry, something went wrong.
|
Ok, I'll draft a PEP. |
Sorry, something went wrong.
|
PEP 601 was rejected (although I think it contains a reasonable seed). |
Sorry, something went wrong.
This reverts commit fe2bbb1.
https://bugs.python.org/issue37830