From b69a3f96455f3333bc70b67f828cda784fc4ac99 Mon Sep 17 00:00:00 2001 From: Christopher Rosell Date: Wed, 26 Sep 2012 14:28:09 +0200 Subject: Fix file check on Python 3. --- src/livestreamer/cli.py | 4 ++-- src/livestreamer/compat.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/livestreamer/cli.py b/src/livestreamer/cli.py index 217ee52..d2a31f6 100644 --- a/src/livestreamer/cli.py +++ b/src/livestreamer/cli.py @@ -5,7 +5,7 @@ import sys import subprocess from livestreamer import * -from livestreamer.compat import input, stdout, is_win32 +from livestreamer.compat import input, stdout, file, is_win32 from livestreamer.stream import StreamProcess from livestreamer.utils import ArgumentParser, NamedPipe @@ -217,7 +217,7 @@ def output_stream(stream, args): if not out: exit("Failed to open a valid stream output") - if is_win32 and type(out) is file: + if is_win32 and isinstance(out, file): import msvcrt msvcrt.setmode(out.fileno(), os.O_BINARY) diff --git a/src/livestreamer/compat.py b/src/livestreamer/compat.py index d91021f..f32fe47 100644 --- a/src/livestreamer/compat.py +++ b/src/livestreamer/compat.py @@ -10,6 +10,7 @@ if is_py2: stdout = sys.stdout _str = str str = unicode + file = file def bytes(b, enc="ascii"): return _str(b) @@ -19,6 +20,7 @@ elif is_py3: input = input stdout = sys.stdout.buffer str = str + from io import IOBase as file try: from urllib.parse import urlparse, urljoin, quote, unquote, parse_qs -- cgit v1.2.3