[issue14565] is_cgi doesn't function as documented for cgi_directories

Pierre Quentel report at bugs.python.org
Mon May 7 08:14:13 CEST 2012


Pierre Quentel <pierre.quentel at gmail.com> added the comment:

Thanks for the explanation

I still think that the patch can be simplified, not using path lengths and the "found" flag

collapsed_path = _url_collapse_path(self.path)
for head in self.cgi_directories:
    if head==collapsed_path:
        self.cgi_info = (head,'')
        return True
    elif collapsed_path.startswith(head) \
        and collapsed_path[len(head)]=='/':
            self.cgi_info = head, collapsed_path[len(head)+1:]
            return True
return False

BTW the last "return False" is rather useless since is_cgi() is only used in tests like "if is_cgi()"

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14565>
_______________________________________


More information about the Python-bugs-list mailing list