From 290462909feedcf8c7daa425e73d021433fbaee5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 7 Mar 2014 21:49:51 +0530 Subject: [PATCH] Linux binary install script: Fix error on linux systems where the system python has an encoding of None set on stdout. Assume encoding is utf-8 in this case. --- setup/linux-installer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup/linux-installer.py b/setup/linux-installer.py index d552279d2e..e70e806b54 100644 --- a/setup/linux-installer.py +++ b/setup/linux-installer.py @@ -16,7 +16,7 @@ url = 'http://status.calibre-ebook.com/dist/linux'+('64' if is64bit else '32') signature_url = 'http://calibre-ebook.com/downloads/signatures/%s.sha512' url = os.environ.get('CALIBRE_INSTALLER_LOCAL_URL', url) py3 = sys.version_info[0] > 2 -enc = getattr(sys.stdout, 'encoding', 'UTF-8') +enc = getattr(sys.stdout, 'encoding', 'UTF-8') or 'utf-8' calibre_version = signature = None urllib = __import__('urllib.request' if py3 else 'urllib', fromlist=1) if py3: @@ -197,7 +197,7 @@ class ProgressBar: def prints(*args, **kwargs): # {{{ f = kwargs.get('file', sys.stdout.buffer if py3 else sys.stdout) end = kwargs.get('end', b'\n') - enc = getattr(f, 'encoding', 'utf-8') + enc = getattr(f, 'encoding', 'utf-8') or 'utf-8' if isinstance(end, unicode): end = end.encode(enc)