Am Sa, den 20.03.2004 schrieb Jakub Piotr Cłapa um 21:23:
> In [3]: import gnome
> 
> In [4]: f
> Out[4]: 0.123123
> 
> In [5]: gnome.init("shit", "more shit")
> Out[5]: <gnome.Program object (GnomeProgram) at 0x406c2694>
> 
> In [6]: f
> Out[6]: 0,123123
> 
> In [7]: f = float("0.123123")
> ---------------------------------------------------------------------------
> ValueError                                Traceback (most recent call last)

Yes, gnome.program_init() does bad things now. It changes the LC_NUMERIC
locale setting which is used to determine if "." or "," is
used as the decimal point.
See http://bugzilla.gnome.org/show_bug.cgi?id=135055

I had the same problems and fixed it like this:

    program = gnome.program_init(NAME, VERSION)
 
    # gnome.program_init has the bad new habit to modify the locale
    # settings (bug #135055); repair it
    import locale; locale.setlocale(locale.LC_NUMERIC, "C")


> When I set LC_ALL to "C" everything works fine. It seems that gnome.init 
> somehow modifies standard python way of handling literals according to 
> the locale. That's a really Bad Thing(TM).

I fully agree. But the real problem is that Python uses locale-sensitive
libc-functions for parsing floats.


Martin Grimme


_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to