Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #1551 -- Improved base handler to not lose track of important e…

…xception in case of exceptions within repr(). Thanks, Ned

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2667 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 51a6d81d72114adc3987d33451c5422eb27bf59a 1 parent 8d70ed4
@adrianholovaty adrianholovaty authored
Showing with 7 additions and 4 deletions.
  1. +7 −4 django/core/handlers/base.py
View
11 django/core/handlers/base.py
@@ -1,4 +1,5 @@
from django.utils import httpwrappers
+import sys
class BaseHandler:
def __init__(self):
@@ -108,12 +109,14 @@ def get_response(self, path, request):
if DEBUG:
return self.get_technical_error_response(request)
else:
+ # Get the exception info now, in case another exception is thrown later.
+ exc_info = sys.exc_info()
subject = 'Coding error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in INTERNAL_IPS and 'internal' or 'EXTERNAL'), getattr(request, 'path', ''))
try:
request_repr = repr(request)
except:
request_repr = "Request repr() unavailable"
- message = "%s\n\n%s" % (self._get_traceback(), request_repr)
+ message = "%s\n\n%s" % (self._get_traceback(exc_info), request_repr)
mail_admins(subject, message, fail_silently=True)
return self.get_friendly_error_response(request, resolver)
@@ -138,7 +141,7 @@ def get_technical_error_response(self, request, is404=False, exception=None):
else:
return debug.technical_500_response(request, *sys.exc_info())
- def _get_traceback(self):
+ def _get_traceback(self, exc_info=None):
"Helper function to return the traceback as a string"
- import sys, traceback
- return '\n'.join(traceback.format_exception(*sys.exc_info()))
+ import traceback
+ return '\n'.join(traceback.format_exception(*(exc_info or sys.exc_info())))
Please sign in to comment.
Something went wrong with that request. Please try again.