diff mercurial/hgweb/wsgicgi.py @ 43077:687b865b95ad

formatting: byteify all mercurial/ and hgext/ string literals Done with python3.7 contrib/byteify-strings.py -i $(hg files 'set:mercurial/**.py - mercurial/thirdparty/** + hgext/**.py - hgext/fsmonitor/pywatchman/** - mercurial/__init__.py') black -l 80 -t py33 -S $(hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**') # skip-blame mass-reformatting only Differential Revision: https://phab.mercurial-scm.org/D6972
author Augie Fackler <augie@google.com>
date Sun, 06 Oct 2019 09:48:39 -0400
parents 2372284d9457
children c59eb1560c44
line wrap: on
line diff
--- a/mercurial/hgweb/wsgicgi.py	Sun Oct 06 09:45:02 2019 -0400
+++ b/mercurial/hgweb/wsgicgi.py	Sun Oct 06 09:48:39 2019 -0400
@@ -24,7 +24,7 @@
     procutil.setbinary(procutil.stdout)
 
     environ = dict(os.environ.iteritems())  # re-exports
-    environ.setdefault(r'PATH_INFO', '')
+    environ.setdefault(r'PATH_INFO', b'')
     if environ.get(r'SERVER_SOFTWARE', r'').startswith(r'Microsoft-IIS'):
         # IIS includes script_name in PATH_INFO
         scriptname = environ[r'SCRIPT_NAME']
@@ -53,18 +53,18 @@
 
     def write(data):
         if not headers_set:
-            raise AssertionError("write() before start_response()")
+            raise AssertionError(b"write() before start_response()")
 
         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' % pycompat.bytesurl(status))
+            out.write(b'Status: %s\r\n' % pycompat.bytesurl(status))
             for hk, hv in response_headers:
                 out.write(
-                    '%s: %s\r\n'
+                    b'%s: %s\r\n'
                     % (pycompat.bytesurl(hk), pycompat.bytesurl(hv))
                 )
-            out.write('\r\n')
+            out.write(b'\r\n')
 
         out.write(data)
         out.flush()
@@ -78,7 +78,7 @@
             finally:
                 exc_info = None  # avoid dangling circular ref
         elif headers_set:
-            raise AssertionError("Headers already set!")
+            raise AssertionError(b"Headers already set!")
 
         headers_set[:] = [status, response_headers]
         return write
@@ -88,6 +88,6 @@
         for chunk in content:
             write(chunk)
         if not headers_sent:
-            write('')  # send headers now if body was empty
+            write(b'')  # send headers now if body was empty
     finally:
         getattr(content, 'close', lambda: None)()