From 21affed28360f484921fbf6e93097efbdaa798d9 Mon Sep 17 00:00:00 2001 From: Bezleputh Date: Sat, 10 Jan 2015 16:56:11 +0100 Subject: [PATCH] handle attribute error when stdout does not habe encoding attribute (ie xbmcout) --- weboob/tools/application/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/weboob/tools/application/base.py b/weboob/tools/application/base.py index 6e4aa37a..7194b5af 100644 --- a/weboob/tools/application/base.py +++ b/weboob/tools/application/base.py @@ -177,7 +177,10 @@ class Application(object): def guess_encoding(self, stdio=None): if stdio is None: stdio = self.stdout - encoding = stdio.encoding or locale.getpreferredencoding() + try: + encoding = stdio.encoding or locale.getpreferredencoding() + except AttributeError: + encoding = None # ASCII or ANSII is most likely a user mistake if not encoding or encoding.lower() == 'ascii' or encoding.lower().startswith('ansi'): encoding = 'UTF-8'