aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2015-10-06 14:28:14 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2015-10-06 14:30:43 +0200
commit4810c48d6d7e950c2cb1203f4d07bea1ba02c1e1 (patch)
tree8a75c643e301b2b24ddeaa08de690b2533cf372e
parentc4af7684d85a17441c5f6f0b6e9f8c470644fec0 (diff)
[compat] Do not compare None <= 0
The result is meaningless (and it emits a warning in cpython2 when called with -3), so handle None before making integer comparisons.
-rw-r--r--youtube_dl/compat.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py
index c36c9c23f..1ba4ab78c 100644
--- a/youtube_dl/compat.py
+++ b/youtube_dl/compat.py
@@ -417,18 +417,18 @@ else:
_terminal_size = collections.namedtuple('terminal_size', ['columns', 'lines'])
def compat_get_terminal_size(fallback=(80, 24)):
- columns = compat_getenv('COLUMNS', None)
+ columns = compat_getenv('COLUMNS')
if columns:
columns = int(columns)
else:
columns = None
- lines = compat_getenv('LINES', None)
+ lines = compat_getenv('LINES')
if lines:
lines = int(lines)
else:
lines = None
- if columns <= 0 or lines <= 0:
+ if columns is None or lines is None or columns <= 0 or lines <= 0:
try:
sp = subprocess.Popen(
['stty', 'size'],
@@ -438,9 +438,9 @@ else:
except Exception:
_columns, _lines = _terminal_size(*fallback)
- if columns <= 0:
+ if columns is None or columns <= 0:
columns = _columns
- if lines <= 0:
+ if lines is None or lines <= 0:
lines = _lines
return _terminal_size(columns, lines)