When the url contains Chinese, like "你", an error occurs.
404, "The path '/ä½\xa0' was not found."
I added 2 lines on cherrypy/_cpwsgi.py line 310, then it works ok.
I do not know why.
# This isn't perfect; if the given PATH_INFO is in the wrong encoding,
# it may fail to match the appropriate config section URI. But meh.
old_enc = self.environ.get('wsgi.url_encoding', 'ISO-8859-1')
new_enc = self.cpapp.find_config(self.environ.get('PATH_INFO', ''),
if new_enc.lower() != old_enc.lower():
# Even though the path and qs are unicode, the WSGI server is
# required by PEP 3333 to coerce them to ISO-8859-1 masquerading
# as unicode. So we have to encode back to bytes and then decode
# again using the "correct" encoding.
u_path = path.encode(old_enc).decode(new_enc)
u_qs = qs.encode(old_enc).decode(new_enc)
# two lines added by me
u_path = u_path.encode(old_enc).decode(new_enc)
u_qs = u_qs.encode(old_enc).decode(new_enc)
except (UnicodeEncodeError, UnicodeDecodeError):
# Just pass them through without transcoding and hope.
# Only set transcoded values if they both succeed.
path = u_path
qs = u_qs
Bugfix, there was a double encoding for the PATH_INFO of the wsgienv,
this was causing an error when uri was using something different than
ISO-8859-1 and wasn't able to find the appropiate method to call
in python3 resulting in a 404.