benoitc/gunicorn — pull request #583 by pypeng (2013-07-30 09:42:16+00:00)
Title: resp maybe None when pre_request raises exceptions

then the response shows something like this:

Internal Server Error

Traceback:

Traceback (most recent call last):
File "/home/vagrant/projects/dae/venv/local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 88, in handle
self.handle_request(listener, req, client, addr)
File "/home/vagrant/projects/dae/dae/gworkers/sync.py", line 19, in handle_request
super(SyncWorker, self).handle_request(*args)
File "/home/vagrant/projects/dae/venv/local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 142, in handle_request
if resp.headers_sent:
AttributeError: 'NoneType' object has no attribute 'headers_sent'

this hides the real exception, which can only be seen in command line logs, and makes beginners hard to find their own bugs.