Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#7871 closed (fixed)

No trailing slash in url causes TypeError with mod_wsgi

Reported by: gsf@… Owned by: Malcolm Tredinnick
Component: Uncategorized Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


My Apache config includes the following line:

WSGIScriptAlias /testing /var/www/testing/django.wsgi

and my django.wsgi looks like this:

import os, sys

path = '/var/www'
if path not in sys.path:

os.environ['DJANGO_SETTINGS_MODULE'] = 'testing.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler() displays correctly, but (without the trailing slash) produces the following error:

File "/usr/lib/python2.5/site-packages/django/core/handlers/" in get_response
  78.                     request.path_info)

Exception Type: TypeError at /testing
Exception Value: 'NoneType' object is not iterable

Change History (5)

comment:1 Changed 12 years ago by Malcolm Tredinnick

Owner: changed from nobody to Malcolm Tredinnick

comment:2 Changed 12 years ago by Malcolm Tredinnick

Triage Stage: UnreviewedAccepted

Gaargh... I used to handle this and then I removed it to fix another bug (forgetting why it was there originally). When I fix it this time, it's definitely getting a comment! Thanks for the clear report.

comment:3 Changed 12 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [8032]) Fixed #7871 -- Added some more bullet-proofing in PATH_INFO determination,
since Django would like it to at least contain a '/' (rather than being an
empty string).

comment:4 Changed 12 years ago by Malcolm Tredinnick

If you can still reproduce this problem, please reopen, but it would be helpful if you could also print what Django thinks self.path and self.path_info are at that point in the process. I'm fairly sure [8032] is the sufficient, though (and shouldn't harm other cases).

comment:5 Changed 12 years ago by Gabriel Farrell

That fixes it for me. Thanks!

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