[proxy] web.archive.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light

/ cpython Public

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

Copy link
Member

serhiy-storchaka commented Aug 12, 2019

Copy link
Sponsor Member

isidentical commented Aug 12, 2019

Then i am closing #15221

Copy link
Member

pablogsal commented Aug 12, 2019

We should also inform @ambv so it removes this from the main announcement of future releases.

Copy link

dpgeorge commented Aug 13, 2019

FWIW I think that continue should never be allowed in a finally clause because it's tricky to implement, and simply should not be used in scripts (I feel the same about break and return in a finally, but that's not really possible to ban at this point). We had similar VM seg-faults in MicroPython for all these "unwinding jumps", see micropython/micropython@b735208 and micropython/micropython@e1fb03f for the fixes (for return and break respectively). Banning this syntax at the compile level would make things simpler.

@ncoghlan FYI we did discuss this topic at PyCon AU 2018

Copy link
Member Author

serhiy-storchaka commented Aug 13, 2019

Actually this reversion does not solve the issue completely: https://bugs.python.org/issue37830#msg349513. So it does not make sense to do it.

Copy link
Contributor

ncoghlan commented Aug 13, 2019

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.

Copy link
Member

vstinner left a 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.

Copy link
Member Author

serhiy-storchaka commented Aug 13, 2019

I have closed this issue because I do not see any sense in reverting changes for continue if there is the same issue with break. At least continue is not used in existing code, so it will not crash any program.

Copy link
Contributor

ncoghlan commented Aug 14, 2019

@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.

ncoghlan reopened this Aug 14, 2019
Copy link

dpgeorge commented Aug 15, 2019

The request from MicroPython was to reconsider allowing this construct at all.

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.

Copy link
Contributor

ncoghlan commented Aug 15, 2019

@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.

Copy link

dpgeorge commented Aug 16, 2019

Ok, I'll draft a PEP.

Copy link
Member Author

serhiy-storchaka commented Oct 2, 2019

PEP 601 was rejected (although I think it contains a reasonable seed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants