[Python-checkins] cpython: get_terminal_size() can also fail with ENOTTY if the fd is not connected to a
antoine.pitrou
python-checkins at python.org
Thu Feb 9 00:13:49 CET 2012
http://hg.python.org/cpython/rev/3ed8b4f3f309
changeset: 74837:3ed8b4f3f309
user: Antoine Pitrou <solipsis at pitrou.net>
date: Thu Feb 09 00:11:00 2012 +0100
summary:
get_terminal_size() can also fail with ENOTTY if the fd is not connected to a terminal.
files:
Lib/test/test_os.py | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -1851,7 +1851,7 @@
try:
size = os.get_terminal_size()
except OSError as e:
- if e.errno == errno.EINVAL or sys.platform == "win32":
+ if sys.platform == "win32" or e.errno in (errno.EINVAL, errno.ENOTTY):
# Under win32 a generic OSError can be thrown if the
# handle cannot be retrieved
self.skipTest("failed to query terminal size")
@@ -1873,7 +1873,14 @@
self.skipTest("stty invocation failed")
expected = (int(size[1]), int(size[0])) # reversed order
- actual = os.get_terminal_size(sys.__stdin__.fileno())
+ try:
+ actual = os.get_terminal_size(sys.__stdin__.fileno())
+ except OSError as e:
+ if sys.platform == "win32" or e.errno in (errno.EINVAL, errno.ENOTTY):
+ # Under win32 a generic OSError can be thrown if the
+ # handle cannot be retrieved
+ self.skipTest("failed to query terminal size")
+ raise
self.assertEqual(expected, actual)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list