Last active
November 2, 2016 20:43
-
-
Save keenhenry/f613350e4796429cf8a98c06f853952f to your computer and use it in GitHub Desktop.
How to bypass try-catch block from the inner function ...
This file contains 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
#!/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