locale.getlocale() strange behaviour

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Benoît Dejean

    locale.getlocale() strange behaviour

    here are my locales


    benoit@athlon >> locale
    LANG=fr_FR.UTF-8
    LC_CTYPE="fr_FR .UTF-8"
    LC_NUMERIC="fr_ FR.UTF-8"
    LC_TIME="fr_FR. UTF-8"
    LC_COLLATE="fr_ FR.UTF-8"
    LC_MONETARY="fr _FR.UTF-8"
    LC_MESSAGES="fr _FR.UTF-8"
    LC_PAPER="fr_FR .UTF-8"
    LC_NAME="fr_FR. UTF-8"
    LC_ADDRESS="fr_ FR.UTF-8"
    LC_TELEPHONE="f r_FR.UTF-8"
    LC_MEASUREMENT= "fr_FR.UTF-8"
    LC_IDENTIFICATI ON="fr_FR.UTF-8"
    LC_ALL=fr_FR.UT F-8



    (full utf-8 system)


    [color=blue][color=green]
    >> python2.3 -c 'import locale; print locale.getlocal e()'[/color][/color]
    (None, None)
    [color=blue][color=green]
    >> python2.2 -c 'import locale; print locale.getlocal e()'[/color][/color]
    (None, None)
    [color=blue][color=green]
    >> python2.3[/color][/color]
    Python 2.3.3 (#2, Feb 24 2004, 09:29:20)
    [GCC 3.3.3 (Debian)] on linux2
    Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
    >>> import locale
    >>> locale.getlocal e()[/color][/color][/color]
    (None, None)

    [color=blue][color=green]
    >> python2.2[/color][/color]
    Python 2.2.3+ (#1, Feb 25 2004, 23:29:31)
    [GCC 3.3.3 (Debian)] on linux2
    Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
    >>> import locale
    >>> locale.getlocal e()[/color][/color][/color]
    ['fr_FR', 'utf']


    2.3 fails getting locale
    but 2.2 also fails when running inline :/

    makes me crazy :D





  • Jeff Epler

    #2
    Re: locale.getlocal e() strange behaviour

    Just as in C programs, the LANG and LC_* environment variables have no
    effect until setlocale is called with "" as the second argument.

    On my system:
    $ echo $LANG
    en_US.UTF-8
    $ python -c 'import locale; print locale.getlocal e()'
    (None, None)
    $ python -c 'import locale; locale.setlocal e(locale.LC_ALL , ""); print locale.getlocal e()'
    ['en_US', 'utf']

    In Python2.2 on my system, setlocale() is called by rl_initialize() when
    I run the interactive interpreter.
    $ python -c 'import locale; import readline; print locale.getlocal e()'
    ['en_US', 'utf']
    this may explain the behavior you noticed.

    Jeff

    Comment

    • Benoît Dejean

      #3
      Re: locale.getlocal e() strange behaviour

      Le Tue, 02 Mar 2004 20:09:26 -0600, Jeff Epler a écrit :[color=blue]
      >
      > In Python2.2 on my system, setlocale() is called by rl_initialize() when
      > I run the interactive interpreter.
      > $ python -c 'import locale; import readline; print locale.getlocal e()'
      > ['en_US', 'utf']
      > this may explain the behavior you noticed.[/color]

      thanks a lot

      Comment

      Working...