From 46ceab3ca87c5906197b46f0093173f10fe9176c Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Wed, 23 Oct 2013 17:03:40 +0000 Subject: [PATCH] Apparently, when running as a script, sys.stdout might not have an encoding svn: r23374 --- gramps/gen/utils/grampslocale.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gramps/gen/utils/grampslocale.py b/gramps/gen/utils/grampslocale.py index 439d2a3ef..61e3425fe 100644 --- a/gramps/gen/utils/grampslocale.py +++ b/gramps/gen/utils/grampslocale.py @@ -415,7 +415,10 @@ class GrampsLocale(object): #Ensure that output is encoded correctly to stdout and stderr. This is #much less cumbersome and error-prone than encoding individual outputs #and better handles the differences between Python 2 and Python 3: - _encoding = sys.stdout.encoding or sys.getdefaultencoding() + try: + _encoding = sys.stdout.encoding or sys.getdefaultencoding() + except: + _encoding = "UTF-8" if sys.version_info[0] < 3: sys.stdout = codecs.getwriter(_encoding)(sys.stdout, 'backslashreplace')