[Python-apps-team] Bug#507774: Bug#507774: phatch uses LC_CTYPE instead of LANG

Emilio Pozuelo Monfort pochu at ubuntu.com
Fri Dec 5 10:28:35 UTC 2008


[Stani, I've attached a patch for this bug, below I explain why I think it's right]

Emmanuel Hainry wrote:
> Package: phatch
> Version: 0.1.6-1
> Severity: normal
> 
> 
> Although I set my locales to speak in english but use french
> conventions:
> Locale: LANG=en_GB.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
> phatch speaks in french. Launching it as
> LC_CTYPE=en_GB.UTF-8 phatch 
> makes it speak in the right language however.

Phatch sets the locale at core/config.py, load_locale function, which uses the
locale python module:

    locale.setlocale(locale.LC_ALL, '')
    #get default canonical if necessary
    if canonical == 'default':
        canonical  = locale.getdefaultlocale()[0]#canonical


From the locale module help:
    getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE'))
        Tries to determine the default locale settings and returns
        them as tuple (language code, encoding).

        According to POSIX, a program which has not called
        setlocale(LC_ALL, "") runs using the portable 'C' locale.
        Calling setlocale(LC_ALL, "") lets it use the default locale as
        defined by the LANG variable. Since we don't want to interfere
        with the current locale setting we thus emulate the behavior
        in the way described above.

        To maintain compatibility with other platforms, not only the
        LANG variable is tested, but a list of variables given as
        envvars parameter. The first found to be defined will be
        used. envvars defaults to the search path used in GNU gettext;
        it must always contain the variable name 'LANG'.

        Except for the code 'C', the language code corresponds to RFC
        1766.  code and encoding can be None in case the values cannot
        be determined.


So it's looking if LC_ALL is set, if not, it looks for LC_CTYPE, then LANG, and
finally LANGUAGE. And as you have LC_CTYPE defined, it will choose that before
the LANG variable.

By looking at those env vars definitions at [1], I think Phatch should discard
LC_CTYPE and use LC_ALL and LANG instead (in that order).

Attached is a patch against trunk that fixes this.

Cheers,
Emilio

[1] http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html#tag_08_02
-------------- next part --------------
A non-text attachment was scrubbed...
Name: phatch_use_correct_lang.patch
Type: text/x-patch
Size: 513 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/python-apps-team/attachments/20081205/2d81d39a/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: OpenPGP digital signature
Url : http://lists.alioth.debian.org/pipermail/python-apps-team/attachments/20081205/2d81d39a/attachment.pgp 


More information about the Python-apps-team mailing list