【发布时间】:2012-01-25 22:49:42
【问题描述】:
我在 django 项目上工作了一段时间,突然 django 的调试停止工作,显示以下异常,而不是在我的代码中显示错误的回溯。
这个异常似乎是调试器本身的问题,并且已经在多个地方进行了讨论,表明它可能是 Mac 中的换行问题 (here) 以及堆栈中的行不匹配和磁盘 (here)。
有趣的是,这个异常只发生在不是由于语法错误引起的异常时。如果我随机添加不正确的语法,django 会显示正常的调试界面,指示“无效语法(views.py,行 xyz)”。
我正在使用 Django 1.3、Python 2.7、Ubuntu 11.04。这个项目有几千行,所以很难复制粘贴到这里。
有没有人也遇到过这个问题并且知道还有哪些其他因素会导致这个问题以及如何解决它?
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/servers/basehttp.py", line 283, in run
self.result = application(self.environ, self.start_response)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__
return self.application(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 273, in __call__
response = self.get_response(request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 169, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 59, in technical_500_response
html = reporter.get_traceback_html()
File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 114, in get_traceback_html
frames = self.get_traceback_frames()
File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 242, in get_traceback_frames
pre_context_lineno, pre_context, context_line, post_context = self._get_lines_from_file(filename, lineno, 7, loader, module_name)
File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 223, in _get_lines_from_file
context_line = source[lineno].strip('\n')
IndexError: list index out of range
【问题讨论】:
标签: python django debugging exception