Mercurial > babel > old > mirror
changeset 300:04d06b162f62
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
author | jruigrok |
---|---|
date | Thu, 13 Dec 2007 11:51:36 +0000 |
parents | f3e1cbfa4738 |
children | 21762d2a345c |
files | babel/messages/frontend.py |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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: