# HG changeset patch # User jruigrok # Date 1197546696 0 # Node ID 257534b131bdfb57b6631f7f3af3e2779e2699dd # Parent 4b840d9f232bf509aea76143555e4d20df362309 When using sys.stdout with a pipe or redirection the sys.stdout.encoding value will be set to None instead of what the environment first specified through any locale setting. As such, fall back to locale.getpreferredencoding() before the ultimate fallback to ASCII. OK: cmlenz closes: #76 diff --git a/babel/messages/frontend.py b/babel/messages/frontend.py --- a/babel/messages/frontend.py +++ b/babel/messages/frontend.py @@ -19,6 +19,7 @@ from distutils import log from distutils.cmd import Command from distutils.errors import DistutilsOptionError, DistutilsSetupError +from locale import getpreferredencoding import logging from optparse import OptionParser import os @@ -632,7 +633,9 @@ for identifier in localedata.list(): locale = Locale.parse(identifier) output = format % (identifier, locale.english_name) - print output.encode(sys.stdout.encoding or 'ascii', 'replace') + print output.encode(sys.stdout.encoding or + getpreferredencoding() or + 'ascii', 'replace') return 0 if not args: