James Henstridge <[EMAIL PROTECTED]> writes:
> On Tue, 23 Feb 1999, Aaron Optimizer Digulla wrote:
>
> > Quoting Andreas Degert <[EMAIL PROTECTED]>:
> >
> > > Hello,
> > >
> > > can anyone confirm this or have an idea what is happening?
> > >
> > > ~$ LANG=en_US python
> > > Python 1.5.1 (#1, Jun 18 1998, 12:39:25) [GCC 2.7.2.3] on linux2
> > > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> > > >>> import gtk
> > > >>> float('0')
> > > Traceback (innermost last):
> > > File "<stdin>", line 1, in ?
> > > ValueError: float() literal too large: 0
> >
It seems to be failing when LC_CTYPE is set to an existing locale at
the time when _gtk.gtk_init is called. May be it's working with a
later gtk library (I'm using gtk+-1.1.13) ?. I've written a little
funktion that can be used as workaround (sorry, at the moment I don't
have the time to dive into python/gtk to find out what's really going
wrong):
####################
import os
def locale_hack():
"""
If LC_CTYPE is set when the module gtk is imported, expressions like
float('0') fail with an exception.
As a workaround this functions sets all LC_* environment variables
except LC_CTYPE from LC_ALL and LANG as defined in the man page
locale(7).
"""
lc_all, lang = None, None
if os.environ.has_key('LC_ALL'): lc_all = os.environ['LC_ALL']
if os.environ.has_key('LANG'): lang = os.environ['LANG']
lc_keys = ('LC_NUMERIC','LC_TIME','LC_COLLATE','LC_MONETARY','LC_MESSAGES')
for key in lc_keys:
if lc_all != None:
os.environ[key] = lc_all
elif not os.environ.has_key(key) and lang != None:
os.environ[key] = lang
for key in ('LC_ALL','LC_CTYPE','LANG'):
os.environ[key] = ''
locale_hack()
import gtk
float('0')
#############
ciao
Andreas
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]