Skip to content

Instantly share code, notes, and snippets.

@keenhenry
Last active November 2, 2016 20:43
Show Gist options
  • Save keenhenry/f613350e4796429cf8a98c06f853952f to your computer and use it in GitHub Desktop.
Save keenhenry/f613350e4796429cf8a98c06f853952f to your computer and use it in GitHub Desktop.
How to bypass try-catch block from the inner function ...
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
def inner():
d = {'b': 1}
try:
d['a']
except:
sys.exit(1)
def outer():
try:
inner()
except SystemExit as se:
print 'system exit ...' # won't be executed!!!
except Exception as e:
raise e
else:
print 'success'
outer()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment