Charset class' behaviour is bad when locale is set to tr_TR. The problems's source is input_charset = input_charset.lower() at line 393 of /usr/lib/python2.3/email/Charset.py . This exeample code can reproduce the error: import locale from email.Charset import Charset locale.setlocale(locale.LC_ALL,("tr_TR","ISO-8859-9")) foo = Charset(locale.nl_langinfo(locale.CODESET)) repr(foo) #Returns \xfdso-8859-9 which is not a charset instead of iso-8859-9 The problem exists because the lower() of I in turkish charset is ý (\xfd), not i. I will try to create and submit a patch ASAP.
Logged In: YES user_id=21627 See the python-dev discussion. My proposal is to add ascii_lower to <type 'str'>, and use that. Charset.py might then use your code as a fallback. Actually, it might be even more performant to do lower_map = string.maketrans(string.ascii_upper, string.ascii_lower) def _ascii_lower(str): return str.translate(lower_map)