#30411: Improve traceback formatting in technical 500 text responses
------------------------------------------------+------------------------
               Reporter:  Daniel Hahler         |          Owner:  nobody
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  Core (Other)          |        Version:  2.2
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 I think it would do better without extra newlines, and could just match
 the default output from Python itself.

 Currently:

 {{{
 Traceback:

 File "…/Vcs/django/django/template/base.py" in __init__
   663.                 token.Meh

 During handling of the above exception ('str' object has no attribute
 'Meh'), another exception occurred:

 File "…/Vcs/django/django/core/handlers/exception.py" in inner
   34.             response = get_response(request)

 File "…/Vcs/django/django/core/handlers/base.py" in _get_response
   145.                 response = self.process_exception_by_middleware(e,
 request)

 File "…/Vcs/django/django/core/handlers/base.py" in _get_response
   143.                 response = response.render()

 File "…/Vcs/django/django/template/response.py" in render
   106.             self.content = self.rendered_content

 File "…/Vcs/django/django/template/response.py" in rendered_content
   83.         content = template.render(context, self._request)

 File "…/Vcs/django/django/template/backends/django.py" in render
   61.             return self.template.render(context)

 File "…/Vcs/django/django/template/base.py" in render
   171.                     return self._render(context)

 File "…/Vcs/django/django/test/utils.py" in instrumented_test_render
   96.     return self.nodelist.render(context)

 File "…/Vcs/django/django/template/base.py" in render
   940.                 bit = node.render_annotated(context)

 File "…/Vcs/django/django/template/base.py" in render_annotated
   907.             return self.render(context)

 File "…/Vcs/django/django/template/loader_tags.py" in render
   150.             return compiled_parent._render(context)

 File "…/Vcs/django/django/test/utils.py" in instrumented_test_render
   96.     return self.nodelist.render(context)

 File "…/Vcs/django/django/template/base.py" in render
   940.                 bit = node.render_annotated(context)

 File "…/Vcs/django/django/template/base.py" in render_annotated
   907.             return self.render(context)

 File "…/Vcs/django/django/template/loader_tags.py" in render
   127.         compiled_parent = self.get_parent(context)

 File "…/Vcs/django/django/template/loader_tags.py" in get_parent
   124.         return self.find_template(parent, context)

 File "…/Vcs/django/django/template/loader_tags.py" in find_template
   104.             template_name, skip=history,

 File "…/Vcs/django/django/template/engine.py" in find_template
   125.                 template = loader.get_template(name, skip=skip)

 File "…/Vcs/django/django/template/loaders/base.py" in get_template
   30.                     contents, origin, origin.template_name,
 self.engine,

 File "…/Vcs/django/django/template/base.py" in __init__
   156.         self.nodelist = self.compile_nodelist()

 File "…/Vcs/django/django/template/base.py" in compile_nodelist
   194.             return parser.parse()

 File "…/Vcs/django/django/template/base.py" in parse
   449.                     raise self.error(token, e)

 File "…/Vcs/django/django/template/base.py" in parse
   447.                     filter_expression =
 self.compile_filter(token.contents)

 File "…/Vcs/django/django/template/base.py" in compile_filter
   563.         return FilterExpression(token, self)

 File "…/Vcs/django/django/template/base.py" in __init__
   666.                                           "from '%s'" %
 (token[upto:], token))

 Exception Type: TemplateSyntaxError at /a/login
 Exception Value: Could not parse the remainder: '("foo")' from
 'myecho("foo")'
 }}}

 Better:
 {{{
 Traceback (most recent call last):
   File "…/Vcs/django/django/template/base.py", line 663, in __init__
     token.Meh

 During handling of the above exception ('str' object has no attribute
 'Meh'), another exception occurred:
   File "…/Vcs/django/django/core/handlers/exception.py", line 34, in inner
     response = get_response(request)
   File "…/Vcs/django/django/core/handlers/base.py", line 145, in
 _get_response
     response = self.process_exception_by_middleware(e, request)
   File "…/Vcs/django/django/core/handlers/base.py", line 143, in
 _get_response
     response = response.render()
   File "…/Vcs/django/django/template/response.py", line 106, in render
     self.content = self.rendered_content
   File "…/Vcs/django/django/template/response.py", line 83, in
 rendered_content
     content = template.render(context, self._request)
   File "…/Vcs/django/django/template/backends/django.py", line 61, in
 render
     return self.template.render(context)
   File "…/Vcs/django/django/template/base.py", line 171, in render
     return self._render(context)
   File "…/Vcs/django/django/test/utils.py", line 96, in
 instrumented_test_render
     return self.nodelist.render(context)
   File "…/Vcs/django/django/template/base.py", line 940, in render
     bit = node.render_annotated(context)
   File "…/Vcs/django/django/template/base.py", line 907, in
 render_annotated
     return self.render(context)
   File "…/Vcs/django/django/template/loader_tags.py", line 150, in render
     return compiled_parent._render(context)
   File "…/Vcs/django/django/test/utils.py", line 96, in
 instrumented_test_render
     return self.nodelist.render(context)
   File "…/Vcs/django/django/template/base.py", line 940, in render
     bit = node.render_annotated(context)
   File "…/Vcs/django/django/template/base.py", line 907, in
 render_annotated
     return self.render(context)
   File "…/Vcs/django/django/template/loader_tags.py", line 127, in render
     compiled_parent = self.get_parent(context)
   File "…/Vcs/django/django/template/loader_tags.py", line 124, in
 get_parent
     return self.find_template(parent, context)
   File "…/Vcs/django/django/template/loader_tags.py", line 104, in
 find_template
     template_name, skip=history,
   File "…/Vcs/django/django/template/engine.py", line 125, in
 find_template
     template = loader.get_template(name, skip=skip)
   File "…/Vcs/django/django/template/loaders/base.py", line 30, in
 get_template
     contents, origin, origin.template_name, self.engine,
   File "…/Vcs/django/django/template/base.py", line 156, in __init__
     self.nodelist = self.compile_nodelist()
   File "…/Vcs/django/django/template/base.py", line 194, in
 compile_nodelist
     return parser.parse()
   File "…/Vcs/django/django/template/base.py", line 449, in parse
     raise self.error(token, e)
   File "…/Vcs/django/django/template/base.py", line 447, in parse
     filter_expression = self.compile_filter(token.contents)
   File "…/Vcs/django/django/template/base.py", line 563, in compile_filter
     return FilterExpression(token, self)
   File "…/Vcs/django/django/template/base.py", line 666, in __init__
     "from '%s'" % (token[upto:], token))

 Exception Type: TemplateSyntaxError at /a/login
 Exception Value: Could not parse the remainder: '("foo")' from
 'myecho("foo")'

 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30411>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.58ef8b72a1cc915d166df8695a23c1ec%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to