-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-37830: Revert "bpo-32489: Allow 'continue' in 'finally' clause. (GH-5822)" #15230
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
bpo-37830: Revert "bpo-32489: Allow 'continue' in 'finally' clause. (GH-5822)" #15230
Conversation
…ythonGH-5822)" This reverts commit fe2bbb1.
Then i am closing #15221 |
We should also inform @ambv so it removes this from the main announcement of future releases. |
FWIW I think that @ncoghlan FYI we did discuss this topic at PyCon AU 2018 |
Actually this reversion does not solve the issue completely: https://bugs.python.org/issue37830#msg349513. So it does not make sense to do it. |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
I have closed this issue because I do not see any sense in reverting changes for |
@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. |
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. |
@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. |
Ok, I'll draft a PEP. |
PEP 601 was rejected (although I think it contains a reasonable seed). |
This reverts commit fe2bbb1.
https://bugs.python.org/issue37830