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

we seem to have lost whence_raised #282

Closed
chadwhitacre opened this issue Jan 10, 2014 · 1 comment · Fixed by #567
Closed

we seem to have lost whence_raised #282

chadwhitacre opened this issue Jan 10, 2014 · 1 comment · Fixed by #567

Comments

@chadwhitacre
Copy link
Contributor

This is another #262 regression. We call sys.exc_clear in algorithm after any exception handler, so the exc_info call in log_result_of_response always returns nothing.

If we were under Python 3, we would have the traceback object stored on the exception. I decided not to shim that for Python 2 in Algorithm.py. We might review that decision, but for now I propose that we modify get_response_for_exception to store the current traceback object on the response, for use downstream in log_result_of_response. Let's be careful not to create a circular reference with the traceback object, per the Python 2 docs:

Warning: Assigning the traceback return value to a local variable in a function that is handling an exception will cause a circular reference. This will prevent anything referenced by a local variable in the same function or by the traceback from being garbage collected. Since most functions don’t need access to the traceback, the best solution is to use something like exctype, value = sys.exc_info()[:2] to extract only the exception type and value. If you do need the traceback, make sure to delete it after use (best done with a try ... finally statement) or to call exc_info() in a function that does not itself handle an exception.

http://docs.python.org/2/library/sys.html#sys.exc_info

@chadwhitacre
Copy link
Contributor Author

I wanted this while debugging gratipay/gratipay.com#2940.

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

Successfully merging a pull request may close this issue.

1 participant