diff mercurial/hgweb/wsgicgi.py @ 30482:39d13b8c101d

py3: bulk replace sys.stdin/out/err by util's Almost all sys.stdin/out/err in hgext/ and mercurial/ are replaced by util's. There are a few exceptions: - lsprof.py and statprof.py are untouched since they are a kind of vendor code and they never import mercurial modules right now. - ui._readline() needs to replace sys.stdin and stdout to pass them to raw_input(). We'll need another workaround here.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 20 Oct 2016 23:53:36 +0900
parents 37fcfe52c68c
children f1c9fafcbf46
line wrap: on
line diff
--- a/mercurial/hgweb/wsgicgi.py	Thu Oct 20 23:40:24 2016 +0900
+++ b/mercurial/hgweb/wsgicgi.py	Thu Oct 20 23:53:36 2016 +0900
@@ -11,7 +11,6 @@
 from __future__ import absolute_import
 
 import os
-import sys
 
 from .. import (
     util,
@@ -22,8 +21,8 @@
 )
 
 def launch(application):
-    util.setbinary(sys.stdin)
-    util.setbinary(sys.stdout)
+    util.setbinary(util.stdin)
+    util.setbinary(util.stdout)
 
     environ = dict(os.environ.iteritems())
     environ.setdefault('PATH_INFO', '')
@@ -33,12 +32,12 @@
         if environ['PATH_INFO'].startswith(scriptname):
             environ['PATH_INFO'] = environ['PATH_INFO'][len(scriptname):]
 
-    stdin = sys.stdin
+    stdin = util.stdin
     if environ.get('HTTP_EXPECT', '').lower() == '100-continue':
-        stdin = common.continuereader(stdin, sys.stdout.write)
+        stdin = common.continuereader(stdin, util.stdout.write)
 
     environ['wsgi.input'] = stdin
-    environ['wsgi.errors'] = sys.stderr
+    environ['wsgi.errors'] = util.stderr
     environ['wsgi.version'] = (1, 0)
     environ['wsgi.multithread'] = False
     environ['wsgi.multiprocess'] = True
@@ -51,7 +50,7 @@
 
     headers_set = []
     headers_sent = []
-    out = sys.stdout
+    out = util.stdout
 
     def write(data):
         if not headers_set: