diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2007-08-17 15:05:54 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2007-08-17 15:05:54 +0000 |
| commit | fcec755f01cfaba2a85bfc9511876debbce98631 (patch) | |
| tree | e990effbcd90e4d405b0f9dcc70cb38e47b6f3dc /django/views/debug.py | |
| parent | 0f92ac52cbf81fb2ac01755c558e2e6ad54700e8 (diff) | |
newforms-admin: Merged from trunk up to [5916]
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@5918 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/views/debug.py')
| -rw-r--r-- | django/views/debug.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/django/views/debug.py b/django/views/debug.py index d2efe76072..cf0b6b5a0b 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -123,10 +123,20 @@ def technical_500_response(request, exc_type, exc_value, tb): 'function': '?', 'lineno': '?', }] + + unicode_hint = '' + if issubclass(exc_type, UnicodeError): + start = getattr(exc_value, 'start', None) + end = getattr(exc_value, 'end', None) + if start is not None and end is not None: + unicode_str = exc_value.args[1] + unicode_hint = smart_unicode(unicode_str[max(start-5, 0):min(end+5, len(unicode_str))], 'ascii', errors='replace') + t = Template(TECHNICAL_500_TEMPLATE, name='Technical 500 template') c = Context({ 'exception_type': exc_type.__name__, 'exception_value': smart_unicode(exc_value, errors='replace'), + 'unicode_hint': unicode_hint, 'frames': frames, 'lastframe': frames[-1], 'request': request, @@ -258,6 +268,7 @@ TECHNICAL_500_TEMPLATE = """ #explanation { background:#eee; } #template, #template-not-exist { background:#f6f6f6; } #template-not-exist ul { margin: 0 0 0 20px; } + #unicode-hint { background:#eee; } #traceback { background:#eee; } #requestinfo { background:#f6f6f6; padding-left:120px; } #summary table { border:none; background:transparent; } @@ -358,6 +369,12 @@ TECHNICAL_500_TEMPLATE = """ </tr> </table> </div> +{% if unicode_hint %} +<div id="unicode-hint"> + <h2>Unicode error hint</h2> + <p>The string that could not be encoded/decoded was: <strong>{{ unicode_hint|escape }}</strong></p> +</div> +{% endif %} {% if template_does_not_exist %} <div id="template-not-exist"> <h2>Template-loader postmortem</h2> |
