Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Path is always set to "/" using unicode wsgi protocol under Python 3 #1350
I am using a cherrypy server with wsgi_version = ("u", 0) under Python 3, and found a bug in _cherrypy.cptree.Tree.call().
The problematic code is the following:
The unicode environment is converted to bytes (in Python 3) in order to assemble the path from SCRIPT_NAME and PATH_INFO. The problem is that after this conversion all keys are bytes objects, so both env1x.get() calls fail and return the empty string. This in turn leads to httputil.urljoin() returning the empty string which is then replaced by "/" in the script_name() call.
So, whatever url you pass to Tree.call() they all get converted to "/". My solution to this problem is to test for py3k before downgrade_wsgi_ux_to_1x(). A patch is attached.
I tried the version 8.1.0 of cherrypy but got the following traceback:
With the following patch applied, all seems to work well :-)