Apparently, when running as a script, sys.stdout might not have an encoding
svn: r23374
This commit is contained in:
parent
bcf43e9a02
commit
46ceab3ca8
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user