A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2018-June/153800.html below:

[Python-Dev] Why not using "except: (...) raise" to cleanup on error?

[Python-Dev] Why not using "except: (...) raise" to cleanup on error?Yury Selivanov yselivanov.ml at gmail.com
Mon Jun 4 12:57:44 EDT 2018
On Mon, Jun 4, 2018 at 12:50 PM Chris Angelico <rosuav at gmail.com> wrote:
>
> On Tue, Jun 5, 2018 at 2:11 AM, Victor Stinner <vstinner at redhat.com> wrote:
[..]
> > For me, it's fine to catch any exception using "except:" if the block
> > contains "raise", typical pattern to cleanup a resource in case of
> > error. Otherwise, there is a risk of leaking open file or not flushing
> > data on disk, for example.
>
> Pardon the dumb question, but why is try/finally unsuitable?

Because try..finally isn't equivalent to try..except?  Perhaps you
should look at the actual code:
https://github.com/python/cpython/blob/b609e687a076d77bdd687f5e4def85e29a044bfc/Lib/asyncio/base_events.py#L1117-L1123

Yury
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4