[issue6981] locale.getdefaultlocale() envvars default code and documentation mismatch
Eugene Crosser cros...@average.org added the comment: I don't know if the solution suggested in the report is right, but I can confirm the the current logic of getdefaultlocale() produces wrong results. I have LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_CTYPE=ru_RU.UTF-8 LC_COLLATE=ru_RU.UTF-8 which means, according to the documentation, Do everything in English, but recognize Russian words and sort according to Russian alphabet. All other software honors that semantics, except Python that returns Russian as the overall default locale: Python 2.7.1+ (r271:86832, Feb 24 2011, 15:00:15) [GCC 4.5.2] on linux2 Type help, copyright, credits or license for more information. import locale print locale.getdefaultlocale() ('ru_RU', 'UTF8') I believe that because LC_CTYPE controls only one specific aspect of the locale, it either should not be used at all, or used only as the last resort when locale cannot be determined from LANG or LANGUAGE. I think that the current search order envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE') is wrong. -- nosy: +crosser ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6981 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6981] locale.getdefaultlocale() envvars default code and documentation mismatch
Eugene Crosser cros...@average.org added the comment: Steffen: can you please be more specific? As I read the seciton 8.2 of the cited document, I do not see a disparity with my statement. There is even an example: For example, if a user wanted to interact with the system in French, but required to sort German text files, LANG and LC_COLLATE could be defined as: LANG=Fr_FR LC_COLLATE=De_DE which is (almost) exactly my case. I have LANG set to en_US to tell the system that I want to interact in English, and LC_CTYPE - to Russian to tell it that classification of characters needs to be Russian-specific. Note that I do *not* have LC_ALL set, because it takes precedence over all other LC_* variables which is *not* what I want. I believe that the correct guessing order, according to the document that you cited, would be: LANG LC_ALL then possibly (possibly because it does not have encoding info) LANGUAGE then optionally, as a last resort LC_CTYPE and other LC_* variables. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6981 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com