Skip to content

Instantly share code, notes, and snippets.

@mahmoud
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahmoud/4b5f274e6e4fcf8cf9b6 to your computer and use it in GitHub Desktop.
Save mahmoud/4b5f274e6e4fcf8cf9b6 to your computer and use it in GitHub Desktop.
exploring the behavior reraising (unexpectedly includes function calls after original raise)
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