summaryrefslogtreecommitdiff
path: root/lib/spack/llnl/util/tty/log.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/spack/llnl/util/tty/log.py')
-rw-r--r--lib/spack/llnl/util/tty/log.py26
1 files changed, 8 insertions, 18 deletions
diff --git a/lib/spack/llnl/util/tty/log.py b/lib/spack/llnl/util/tty/log.py
index e155fa1d26..2d6609c390 100644
--- a/lib/spack/llnl/util/tty/log.py
+++ b/lib/spack/llnl/util/tty/log.py
@@ -241,8 +241,7 @@ class keyboard_input(object):
"""If termios was available, restore old settings."""
if self.old_cfg:
self._restore_default_terminal_settings()
- if sys.version_info >= (3,):
- atexit.unregister(self._restore_default_terminal_settings)
+ atexit.unregister(self._restore_default_terminal_settings)
# restore SIGSTP and SIGCONT handlers
if self.old_handlers:
@@ -323,10 +322,7 @@ class FileWrapper(object):
def unwrap(self):
if self.open:
if self.file_like:
- if sys.version_info < (3,):
- self.file = open(self.file_like, "w")
- else:
- self.file = open(self.file_like, "w", encoding="utf-8") # novm
+ self.file = open(self.file_like, "w", encoding="utf-8")
else:
self.file = StringIO()
return self.file
@@ -699,13 +695,10 @@ class StreamWrapper:
self.sys_attr = sys_attr
self.saved_stream = None
if sys.platform.startswith("win32"):
- if sys.version_info < (3, 5):
- libc = ctypes.CDLL(ctypes.util.find_library("c"))
+ if hasattr(sys, "gettotalrefcount"): # debug build
+ libc = ctypes.CDLL("ucrtbased")
else:
- if hasattr(sys, "gettotalrefcount"): # debug build
- libc = ctypes.CDLL("ucrtbased")
- else:
- libc = ctypes.CDLL("api-ms-win-crt-stdio-l1-1-0")
+ libc = ctypes.CDLL("api-ms-win-crt-stdio-l1-1-0")
kernel32 = ctypes.WinDLL("kernel32")
@@ -927,13 +920,10 @@ def _writer_daemon(
if sys.version_info < (3, 8) or sys.platform != "darwin":
os.close(write_fd)
- # Use line buffering (3rd param = 1) since Python 3 has a bug
+ # 1. Use line buffering (3rd param = 1) since Python 3 has a bug
# that prevents unbuffered text I/O.
- 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")
+ # 2. 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)