Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the purpose of deleting the exception traceback #26

Closed
diwu1989 opened this issue Aug 5, 2015 · 1 comment
Closed

What is the purpose of deleting the exception traceback #26

diwu1989 opened this issue Aug 5, 2015 · 1 comment

Comments

@diwu1989
Copy link

diwu1989 commented Aug 5, 2015

What is the point of these lines:
https://github.com/MindscapeHQ/raygun4py/blob/master/python2/raygun4py/raygunprovider.py#L78-L81

The line that's weird is:

try:
  delete ...
except Exception e:
  raise

isnt that equivalent to just straight up

delete ...

without the try except?
and why do you even need to delete those local variables, they'll get garbage collected at the interpreter's discretion

@fundead
Copy link
Contributor

fundead commented Aug 6, 2015

As it turns out they will not in fact be GC'd, as a function that is handling an exception, if the traceback is assigned to a local variable, will result in a circular reference, This is noted in the official documentation at https://docs.python.org/2/library/sys.html#sys.exc_info, in the Warning and Note blocks, and the above code is the recommended approach. Similar implementations exist in other libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants