Opened 10 years ago

Closed 10 years ago

Last modified 10 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: UI/UX:

Description

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:
    sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'testing.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

http://example.com/testing/ displays correctly, but http://example.com/testing (without the trailing slash) produces the following error:

Traceback:
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py" 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 10 years ago by Malcolm Tredinnick

Owner: changed from nobody to Malcolm Tredinnick

comment:2 Changed 10 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 10 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 10 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 10 years ago by Gabriel Farrell

That fixes it for me. Thanks!

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