From 34496ac2e519e41750b0140a92dd36d54e010a95 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 4 Feb 2016 11:33:34 +0200 Subject: Encode to locale for stdout, stderr; release 0.22 --- yarn | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'yarn') diff --git a/yarn b/yarn index f1cabb3..2e336b0 100755 --- a/yarn +++ b/yarn @@ -19,6 +19,7 @@ import cliapp import collections +import locale import logging import os import re @@ -106,12 +107,16 @@ class YarnRunner(cliapp.Application): default=False) def stdout(self, msg): - self.output.write(msg) - self.output.flush() + self._write(sys.stdout, msg) def stderr(self, msg): - sys.stderr.write(msg) - sys.stderr.flush() + self._write(sys.stderr, msg) + + def _write(self, output, msg): + if isinstance(msg, unicode): + msg = msg.encode(locale.getpreferredencoding()) + output.write(msg) + output.flush() def info(self, indent, msg): if self.settings['verbose']: -- cgit v1.2.1