handle attribute error when stdout does not habe encoding attribute (ie xbmcout)

This commit is contained in:
Bezleputh 2015-01-10 16:56:11 +01:00 committed by Romain Bignon
commit 21affed283

View file

@ -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'