Message 86327 - Python tracker (original) (raw)
OK, it turns out that this is one of a class of known bugs of long standing (see and , for example). The recommended solution is to not use locale.getdefaultlocale, but to use locale.getperferredencoding. I have confirmed that that works for the case of ca_ES.UTF-8@valencia in python2.5.
There is at least a doc bug here, since no mention of this fragility/recommendation is made in the getdefaultlocale documentation.
Using getpreferredencoding seems to be the correct solution to your problem. However, the locale.py module contains a number of examples of modifiers in the locale_alias table. Presumably this case could be added, but it is not clear to me what the policy is on that at this time, so I'm adding Martin to the nosy list looking for some guidance.