From 7efc4e8b99bbb6f85ce174f2c484090cb3bc8191 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Tue, 30 May 2017 17:52:55 -0500 Subject: [PATCH] BUG: Fixed tput output on windows (#16496) --- doc/source/whatsnew/v0.20.2.txt | 2 ++ pandas/io/formats/terminal.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/doc/source/whatsnew/v0.20.2.txt b/doc/source/whatsnew/v0.20.2.txt index 13365401f1d1c..7b7f9e8745809 100644 --- a/doc/source/whatsnew/v0.20.2.txt +++ b/doc/source/whatsnew/v0.20.2.txt @@ -37,6 +37,8 @@ Performance Improvements Bug Fixes ~~~~~~~~~ +- Silenced a warning on some Windows environments about "tput: terminal attributes: No such device or address" when + detecting the terminal size. This fix only applies to python 3 (:issue:`16496`) - Bug in using ``pathlib.Path`` or ``py.path.local`` objects with io functions (:issue:`16291`) - Bug in ``DataFrame.update()`` with ``overwrite=False`` and ``NaN values`` (:issue:`15593`) diff --git a/pandas/io/formats/terminal.py b/pandas/io/formats/terminal.py index dadd09ae74ea4..30bd1d16b538a 100644 --- a/pandas/io/formats/terminal.py +++ b/pandas/io/formats/terminal.py @@ -14,6 +14,8 @@ from __future__ import print_function import os +import sys +import shutil __all__ = ['get_terminal_size'] @@ -26,6 +28,10 @@ def get_terminal_size(): IPython zmq frontends, or IDLE do not run in a terminal, """ import platform + + if sys.version_info[0] >= 3: + return shutil.get_terminal_size() + current_os = platform.system() tuple_xy = None if current_os == 'Windows':