Opened 10 years ago

Closed 10 years ago

Last modified 10 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: master
Severity: normal Keywords:
Cc: md@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


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 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] 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/", 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/", 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/", 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/", 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/", line 19, in __repr__
    return '<ModPythonRequest\
META:%s>' % \\
  File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/handlers/", line 51, in _get_post
  File "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/handlers/", 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/", line 56, in parse_file_upload
    name_dict = parse_header(submessage['Content-Disposition'])[1]
  File "/usr/local/lib/python2.4/", 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@… 10 years ago.

Download all attachments as: .zip

Change History (4)

Changed 10 years ago by md@…

comment:1 Changed 10 years ago by Malcolm Tredinnick

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 Changed 10 years ago by James Bennett

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

comment:3 Changed 10 years ago by James Bennett

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

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