-
Notifications
You must be signed in to change notification settings - Fork 888
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -606,6 +606,8 @@ def invoke_exception_view( | |||
# have been mutated by the view, and its state is not | ||||
# sane (e.g. caching headers) | ||||
with hide_attrs(request, 'exception', 'exc_info', 'response'): | ||||
attrs['exception'] = exc_info[0] | ||||
attrs['exc_info'] = exc_info | ||||
# we use .get instead of .__getitem__ below due to | ||||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mmerickel
Author
Member
|
except Exception as exc: |
I can't just get rid of it unless you want to start that as a separate discussion. :-) It'd be good to focus comments here on how to fix the usage of exc_info.
This comment has been minimized.
This comment has been minimized.
Sorry, something went wrong.
digitalresistor
Mar 2, 2016
Member
hide_attrs
is going to remove the item from the request anyway and restore the original, if any.
This comment has been minimized.
This comment has been minimized.
Sorry, something went wrong.
mmerickel
Mar 2, 2016
Author
Member
hide_attrs is going to remove the item from the request anyway and restore the original, if any.
Yeah that doesn't solve the issue with the local reference to the exc_info on the stack frame.
1 comment
on commit 68b303a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a little thought I'm fairly certain the reference cycle isn't possible here. The issue would be when sys.exc_info()
is called from within the stack frame that caught the exception. At that point the current stack frame (containing the except
) would be referenced by the exc_info
var and vice-versa the exc_info
references the current stack frame. However since we are inside of invoke_exception_view
which is not directly catching the exception - it is a different stack frame that is not on the stack tracked by exc_info
. Thus the reference cycle should not occur and exc_info
should gc correctly.
def foo():
try:
raise RuntimeError
except:
exc_info = sys.exc_info() # references current frame
def handle_exc():
exc_info = sys.exc_info() # should not be circular
def foo():
try:
raise RuntimeError
except:
handle_exc()
How are you dealing with the possible cycles involved in saving the traceback to a local?