pastoob: Don't crash if sys.stdout.encoding is None

This commit is contained in:
Laurent Bachelier 2011-05-31 15:59:12 +02:00
commit 0a73b9e963

View file

@ -62,7 +62,7 @@ class Pastoob(ReplApplication):
if not paste:
print >>sys.stderr, 'Unable to handle paste: %s' % _id
return 1
output = codecs.getwriter(sys.stdout.encoding)(sys.stdout)
output = codecs.getwriter(sys.stdout.encoding or locale.getpreferredencoding())(sys.stdout)
output.write(paste.contents)
# add a newline unless we are writing
# in a file or in a pipe