diff -r c229a1540701 Lib/locale.py --- a/Lib/locale.py Fri Feb 01 17:56:30 2008 +0100 +++ b/Lib/locale.py Fri Feb 01 19:43:30 2008 +0100 @@ -12,6 +12,7 @@ """ import sys, encodings, encodings.aliases +import functools from builtins import str as _builtin_str # Try importing the _locale module. @@ -87,6 +88,24 @@ except ImportError: Returns a string that behaves for cmp locale-aware. """ return s + + +# +# _locale.localeconv() does not have any knowledge of the current encoding, +# so we wrap it here to re-encode the various strings contained in the result. +# +_localeconv = localeconv + +@functools.wraps(_localeconv) +def localeconv(): + d = _localeconv() + enc = getlocale(LC_MONETARY)[1] + # enc may be None + if enc: + for k, v in d.items(): + if isinstance(v, _builtin_str): + d[k] = v.encode('latin_1').decode(enc, 'replace') + return d ### Number formatting APIs