Created
November 24, 2013 03:35
-
-
Save nosamanuel/7623004 to your computer and use it in GitHub Desktop.
try/finally in a bare except block can safely re-raise the original error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def do_something(): | |
| raise RuntimeError('do_something') | |
| def clean_up(): | |
| raise RuntimeError('clean_up') | |
| def fail_in_exception(): | |
| try: | |
| do_something() | |
| except: | |
| try: | |
| clean_up() | |
| finally: | |
| raise | |
| fail_in_exception() # RuntimeError: do_something |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment