Opened 19 years ago

Closed 19 years ago

#1788 closed defect (fixed)

sometimes tecnhical_500_response fails

Reported by: anonymous Owned by: Adrian Holovaty
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In django.views.debug.py the following code fails:


pre_context_lineno, pre_context, context_line, post_context = _get_lines_from_file(filename, lineno, 7)
        frames.append({
            'tb': tb,
            'filename': filename,
            'function': function,
            'lineno': lineno + 1,
            'vars': tb.tb_frame.f_locals.items(),
            'id': id(tb),
            'pre_context': pre_context,
            'context_line': context_line,
            'post_context': post_context,
            'pre_context_lineno': pre_context_lineno + 1,
        })

It fails on 'pre_context_lineno + 1' in case pre_context_lineno is None (cannot apply '+' to None and 1).
This happens when django can't find the source file where the error occurred. To reproduce:

  1. In a view, import some module from a directory in your PYTHONPATH, other than the path to django,

and directory from which web server starts.

  1. Call some method in this module, which raises an exception. Django will not find the source, and produce a backtrace like this:
Traceback (most recent call last):

  File "/home/valeriyz/django/django/core/servers/basehttp.py", line 272, in run
    self.result = application(self.environ, self.start_response)

  File "/home/valeriyz/django/django/core/servers/basehttp.py", line 615, in __call__
    return self.application(environ, start_response)

  File "/home/valeriyz/django/django/core/handlers/wsgi.py", line 145, in __call__
    response = self.get_response(request.path, request)

  File "/home/valeriyz/django/django/core/handlers/base.py", line 100, in get_response
    return self.get_technical_error_response(request)

  File "/home/valeriyz/django/django/core/handlers/base.py", line 133, in get_technical_error_response
    return debug.technical_500_response(request, *sys.exc_info())

  File "/home/valeriyz/django/django/views/debug.py", line 99, in technical_500_response
    frames.append({

TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

Change History (2)

comment:2 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

I believe this was fixed last week.

Note: See TracTickets for help on using tickets.
Back to Top