From 26d0ff1fab7b61bb9ffbb8f449dfc7a578c53e13 Mon Sep 17 00:00:00 2001 From: Max Nordlund gmail Date: Tue, 2 Jan 2018 12:47:15 +0100 Subject: [PATCH] Fix broken import of os.environ.get It's not a module, but a dict-like object. This makes sure to use it like that. In order to replicate the old behavior, this does not use .get with a default value and instead returns None. --- tqdm/_utils.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tqdm/_utils.py b/tqdm/_utils.py index 81ac39e8..4380a251 100644 --- a/tqdm/_utils.py +++ b/tqdm/_utils.py @@ -224,12 +224,10 @@ def _environ_cols_linux(fp): # pragma: no cover try: return array('h', ioctl(fp, TIOCGWINSZ, '\0' * 8))[1] except: - try: - from os.environ import get - except ImportError: - return None + if 'COLUMNS' in os.environ: + return int(os.environ['COLUMNS']) - 1 else: - return int(get('COLUMNS', 1)) - 1 + return None def _term_move_up(): # pragma: no cover