Skip to content

Instantly share code, notes, and snippets.

@nosamanuel
Created November 24, 2013 03:35
Show Gist options
  • Select an option

  • Save nosamanuel/7623004 to your computer and use it in GitHub Desktop.

Select an option

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