# HG changeset patch # User Augie Fackler # Date 1523675506 14400 # Node ID 2d5b5bcc3b9fcfdf227bde28bf11899028f21dce # Parent b29f490eb9047d4cda0fb4eea8d12628d05695af wsgicgi: un-do some prior porting work that is now wrong The Python 3 WSGI behavior is that the environ dict should be full of unicodes. We previously tried Too Hard here, so we unwind that bit of porting. Also add some bytesurl() encodes on status and headers. test-clone-cgi.t now passes. Differential Revision: https://phab.mercurial-scm.org/D3356 diff -r b29f490eb904 -r 2d5b5bcc3b9f contrib/python3-whitelist --- a/contrib/python3-whitelist Fri Apr 13 22:36:54 2018 -0400 +++ b/contrib/python3-whitelist Fri Apr 13 23:11:46 2018 -0400 @@ -45,6 +45,7 @@ test-check-pylint.t test-check-shbang.t test-children.t +test-clone-cgi.t test-clone-pull-corruption.t test-clone-r.t test-clone-update-order.t diff -r b29f490eb904 -r 2d5b5bcc3b9f mercurial/hgweb/wsgicgi.py --- a/mercurial/hgweb/wsgicgi.py Fri Apr 13 22:36:54 2018 -0400 +++ b/mercurial/hgweb/wsgicgi.py Fri Apr 13 23:11:46 2018 -0400 @@ -10,8 +10,10 @@ from __future__ import absolute_import +import os + from .. import ( - encoding, + pycompat, ) from ..utils import ( @@ -26,7 +28,7 @@ procutil.setbinary(procutil.stdin) procutil.setbinary(procutil.stdout) - environ = dict(encoding.environ.iteritems()) + environ = dict(os.environ.iteritems()) # re-exports environ.setdefault(r'PATH_INFO', '') if environ.get(r'SERVER_SOFTWARE', r'').startswith(r'Microsoft-IIS'): # IIS includes script_name in PATH_INFO @@ -61,9 +63,10 @@ elif not headers_sent: # Before the first output, send the stored headers status, response_headers = headers_sent[:] = headers_set - out.write('Status: %s\r\n' % status) - for header in response_headers: - out.write('%s: %s\r\n' % header) + out.write('Status: %s\r\n' % pycompat.bytesurl(status)) + for hk, hv in response_headers: + out.write('%s: %s\r\n' % (pycompat.bytesurl(hk), + pycompat.bytesurl(hv))) out.write('\r\n') out.write(data)