Commit 96948957 authored by Manuel Jacob's avatar Manuel Jacob
Browse files

pycompat: remove pycompat.{stdin,stdout,stderr}

All users have been changed to use procutil.{stdin,stdout,stderr}, which provide
consistent behavior across platforms and Python versions.
parent 4c1b4805db57
...@@ -142,17 +142,6 @@ ...@@ -142,17 +142,6 @@
long = int long = int
# Warning: sys.stdout.buffer and sys.stderr.buffer do not necessarily have
# the same buffering behavior as sys.stdout and sys.stderr. The interpreter
# initializes them with block-buffered streams or unbuffered streams (when
# the -u option or the PYTHONUNBUFFERED environment variable is set), never
# with a line-buffered stream.
# TODO: .buffer might not exist if std streams were replaced; we'll need
# a silly wrapper to make a bytes stream backed by a unicode one.
stdin = sys.stdin.buffer
stdout = sys.stdout.buffer
stderr = sys.stderr.buffer
if getattr(sys, 'argv', None) is not None: if getattr(sys, 'argv', None) is not None:
# On POSIX, the char** argv array is converted to Python str using # On POSIX, the char** argv array is converted to Python str using
# Py_DecodeLocale(). The inverse of this is Py_EncodeLocale(), which # Py_DecodeLocale(). The inverse of this is Py_EncodeLocale(), which
...@@ -476,9 +465,6 @@ ...@@ -476,9 +465,6 @@
osaltsep = os.altsep osaltsep = os.altsep
osdevnull = os.devnull osdevnull = os.devnull
long = long long = long
stdin = sys.stdin
stdout = sys.stdout
stderr = sys.stderr
if getattr(sys, 'argv', None) is not None: if getattr(sys, 'argv', None) is not None:
sysargv = sys.argv sysargv = sys.argv
sysplatform = sys.platform sysplatform = sys.platform
......
...@@ -80,9 +80,16 @@ ...@@ -80,9 +80,16 @@
return LineBufferedWrapper(stream) return LineBufferedWrapper(stream)
stderr = pycompat.stderr if pycompat.ispy3:
stdin = pycompat.stdin # TODO: .buffer might not exist if std streams were replaced; we'll need
stdout = pycompat.stdout # a silly wrapper to make a bytes stream backed by a unicode one.
stdin = sys.stdin.buffer
stdout = sys.stdout.buffer
stderr = sys.stderr.buffer
else:
stdin = sys.stdin
stdout = sys.stdout
stderr = sys.stderr
if pycompat.iswindows: if pycompat.iswindows:
stdout = platform.winstdout(stdout) stdout = platform.winstdout(stdout)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment