Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#2745 closed defect (fixed)

[patch] make modpython error handler not barf on errors

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

Description

I ran into situations where error handling broke because of mangeled errors resulting in ugly "Internal Server Error" messages(see below). It turned out that ModPythonRequest.__repr__() is used when reporting errors and ModPythonRequest.__repr__() relies in too much being sane to do it's job. The patch at http://c0re.23.nu/c0de/misc/django-3764-error_reporting_error.diff basically uses inelegat but effective try: [...] except: [...] blocks to avoid an error while error reporting.

Sampe Error:

Internal Server Error ...

[Sat Sep 16 12:14:51 2006] [error] [client 80.130.106.15] PythonHandler django.core.handlers.modpython: TemplateSyntaxError: Caught an exception while rendering: 'NoneType' object has no attribute 'split'

Original Traceback (most recent call last):
  File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/template/__init__.py", line 704, in render_node
    result = node.render(context)
  File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/template/defaulttags.py", line 189, in render
    value = bool_expr.resolve(context, True)
  File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/template/__init__.py", line 550, in resolve
    obj = resolve_variable(self.var, context)
  File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/template/__init__.py", line 655, in resolve_variable
    raise VariableDoesNotExist, "Failed lookup for key [%s] in %r" % (bits[0], current) # missing attribute
  File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/handlers/modpython.py", line 19, in __repr__
    return '<ModPythonRequest\
path:%s,\
GET:%s,\
POST:%s,\
COOKIES:%s,\
META:%s>' % \\
  File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/handlers/modpython.py", line 51, in _get_post
    self._load_post_and_files()
  File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/handlers/modpython.py", line 32, in _load_post_and_files
    self._post, self._files = http.parse_file_upload(self._req.headers_in, self.raw_post_data)
  File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/http/__init__.py", line 56, in parse_file_upload
    name_dict = parse_header(submessage['Content-Disposition'])[1]
  File "/usr/local/lib/python2.4/cgi.py", line 331, in parse_header
    plist = map(lambda x: x.strip(), line.split(';'))
AttributeError: 'NoneType' object has no attribute 'split'
, referer: [...]

Attachments (1)

django-3764-error_reporting_error.diff.txt (1.1 KB ) - added by md@… 18 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 by Malcolm Tredinnick, 18 years ago

Resolution: fixed
Status: newclosed

(In [3820]) Fixed #2745 -- Made the repr methods for modpython and wsgi request more
robust in the face of bad input, since they are needed for error handling.
Based on a patch from md@….

comment:2 by James Bennett, 18 years ago

(In [4098]) 0.91-bugfixes: Backport [3820] to 0.91-bugfixes, refs #2745.

comment:3 by James Bennett, 18 years ago

(In [4099]) 0.91-bugfixes: Backport [3820] to 0.91-bugfixes, refs #2745.

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