[gtk-doc] common: handle encoding when redirecting stdout under python2
- From: Stefan Sauer <stefkost src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-doc] common: handle encoding when redirecting stdout under python2
- Date: Fri, 23 Jun 2017 14:56:43 +0000 (UTC)
commit 0b348f6757039110719932b699addc7498b89163
Author: Stefan Sauer <ensonic users sf net>
Date: Wed Jun 21 14:50:12 2017 +0200
common: handle encoding when redirecting stdout under python2
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=783926
gtkdoc/common.py | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/gtkdoc/common.py b/gtkdoc/common.py
index f93b72e..09e7bc0 100644
--- a/gtkdoc/common.py
+++ b/gtkdoc/common.py
@@ -45,6 +45,10 @@ def setup_logging():
logging.basicConfig(stream=sys.stdout,
level=logging.getLevelName(log_level.upper()),
format='%(asctime)s:%(filename)s:%(funcName)s:%(lineno)d:%(levelname)s:%(message)s')
+ # When redirecting the output on python2 we get UnicodeEncodeError:
+ if not sys.stdout.encoding:
+ import codecs
+ sys.stdout = codecs.getwriter('utf8')(sys.stdout)
def UpdateFileIfChanged(old_file, new_file, make_backup):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]