[mod_python] Oops, found a small bug in the session code

Graham Dumpleton grahamd at dscpl.com.au
Wed Jun 15 19:42:38 EDT 2005

Dan Eloff wrote ..
> Just discovered this.
> # XXX Not sure why, but on Win32 hlist.directory
> # may contain a trailing \ - need to investigate,
> # this value is given to us directly by httpd
> if os.name == 'nt' and c.path[-1] == '\\':
>     c.path = c.path[:-1]

The underlying problem is a known issue. The hack in the session
code was presumably put there because someone didn't understand
the root cause. Anyway, the underlying problem has already been
fixed for 3.2 and the hack in Session code removed.

> # Sometimes there is no path, e.g. when Location
> # is used. When Alias or UserDir are used, then
> # the path wouldn't match the URI. In those cases
> # just default to '/'
> if not c.path or not self._req.uri.startswith(c.path):
>     c.path = '/'
> In the first if statement, c.path[-1] will throw IndexError if c.path
> is empty (which is possible if you read the next comment). You should
> change it to:
> if os.name == 'nt' and (c.path and c.path[-1] == '\\'):
>     c.path = c.path[:-1]

Also a known issue which I believe has been fixed for 3.2. You can
avoid the problem for now by setting ApplicationPath directive to
some value.

In general, would not recommend enabling of mod_python within a
Location directive as could cause other things to fail that expect to
be able to determine the physical directory context in which they are
being used. In other words use Directory directive instead.

Thanks for highlighting the issues as sometimes we might not know
about such things. For reference, various bugs and there status are
cataloged at:



More information about the Mod_python mailing list