summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/llnl/util/tty/log.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/spack/llnl/util/tty/log.py b/lib/spack/llnl/util/tty/log.py
index ef14baeacf..337eb0ac68 100644
--- a/lib/spack/llnl/util/tty/log.py
+++ b/lib/spack/llnl/util/tty/log.py
@@ -321,7 +321,10 @@ class FileWrapper(object):
def unwrap(self):
if self.open:
if self.file_like:
- self.file = open(self.file_like, 'w')
+ if sys.version_info < (3,):
+ self.file = open(self.file_like, 'w')
+ else:
+ self.file = open(self.file_like, 'w', encoding='utf-8')
else:
self.file = StringIO()
return self.file
@@ -722,7 +725,11 @@ def _writer_daemon(stdin_multiprocess_fd, read_multiprocess_fd, write_fd, echo,
# Use line buffering (3rd param = 1) since Python 3 has a bug
# that prevents unbuffered text I/O.
- in_pipe = os.fdopen(read_multiprocess_fd.fd, 'r', 1)
+ if sys.version_info < (3,):
+ in_pipe = os.fdopen(read_multiprocess_fd.fd, 'r', 1)
+ else:
+ # Python 3.x before 3.7 does not open with UTF-8 encoding by default
+ in_pipe = os.fdopen(read_multiprocess_fd.fd, 'r', 1, encoding='utf-8')
if stdin_multiprocess_fd:
stdin = os.fdopen(stdin_multiprocess_fd.fd)