Last active
August 29, 2015 14:07
-
-
Save mahmoud/4b5f274e6e4fcf8cf9b6 to your computer and use it in GitHub Desktop.
exploring the behavior reraising (unexpectedly includes function calls after original raise)
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
def raise_it(): | |
raise | |
def do_it(): | |
try: | |
dumb() | |
except: | |
raise_it() | |
do_it() | |
# OUTPUT | |
""" | |
# note the stack trace includes the new function call | |
# in other words, the exception did not necessarily happen in the bottom-most frame | |
$ python _tmp.py | |
Traceback (most recent call last): | |
File "_tmp.py", line 11, in <module> | |
do_it() | |
File "_tmp.py", line 9, in do_it | |
raise_it() | |
File "_tmp.py", line 7, in do_it | |
dumb() | |
NameError: global name 'dumb' is not defined | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment