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/2017-June/148331.html below:

[Python-Dev] Handle errors in cleanup code

[Python-Dev] Handle errors in cleanup code [Python-Dev] Handle errors in cleanup codeStefan Ring stefanrin at gmail.com
Mon Jun 12 09:29:00 EDT 2017
> Yury in the comment for PR 2108 [1] suggested more complicated code:
>
>     do_something()
>     try:
>         do_something_other()
>     except BaseException as ex:
>         try:
>             undo_something()
>         finally:
>             raise ex

And this is still bad, because it loses the back trace. The way we do it is:

    do_something()
    try:
        do_something_other()
    except BaseException as ex:
        tb = sys.exc_info()[2]
        try:
            undo_something()
        finally:
            raise ex, None, tb
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