Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#7871 closed (fixed)

No trailing slash in url causes TypeError with mod_wsgi

Reported by: gsf@… Owned by: mtredinnick
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 7 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to mtredinnick
  • Patch needs improvement unset

comment:2 Changed 7 years ago by mtredinnick

  • Triage Stage changed from Unreviewed to Accepted

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 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(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 7 years ago by mtredinnick

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 7 years ago by gsf

That fixes it for me. Thanks!

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