[PythonCE] Python 2.4.3 for Windows CE / ARM

Luke Dunstan coder_infidel at hotmail.com
Sat Apr 8 18:37:06 CEST 2006


----- Original Message ----- 
From: "Giovanni Petrucciani" <gpetruc at gmail.com>
To: "Jan Ischebeck" <mail at jan-ischebeck.de>
Cc: <pythonce at python.org>
Sent: Saturday, April 08, 2006 9:32 PM
Subject: Re: [PythonCE] Python 2.4.3 for Windows CE / ARM


> Jan Ischebeck wrote:
>> Dear Luke,
>>
>> both float("2,2") and float("2.2") don't work. They raise an
>> "ValueError: invalid literal for float(): 2.2".
>> Current locale is "Deutsch" (german word for "german"). After setting
>> the locale to LC_ALL it is still
>> "Deutsch".
>>
>> According to localeconv| 'decimal_point' is "," but this should not have
>> any influence on float(),
>> as there is a specific locale depend function for this conversion.
>>
>> When I call locale.atof("2,2") I get the following error:
>> Traceback(most recent call last):
>> File "binaries\lib\locale.py", line 173, in atof
>> ValueError: invalid literal for float():2.2
>>
>> Although the locale stuff seems to be somehow mixed up, could it be that
>> float("") is
>> calling a locale depend wince function in python 2.4 ?
>>
>
> I experience the same problem with an italian version of Windows CE.
>
> I didn't suppose float was localized (and, as it happens for you too)
> float("2,2") does not work eiher
> This has also bad consequences, as float() is used everywhere; for
> example now you cannot load Tkinter (which does float('8.4') ...)
>
> IMHO float(x) shoud not use the localized version (otherwise
> float(str(x)) != x  even for simple x like 0.5 .... this is really bad)

Looking at the source code for float() in floatobject.c, it calls 
PyOS_ascii_strtod() in pystrtod.c. This function then calls localeconv() to 
find the decimal point character for the current locale and if it is not '.' 
then the function translates any '.' in the input string to the locale 
decimal point. After this conversion it calls the C library strtod() 
function. This means that float() should work with either '.' or ',' for 
Italian/German locales and you can test this on the PC (as opposed to 
WinCE):

>>> locale.setlocale(locale.LC_NUMERIC, 'Italian')
'Italian_Italy.1252'
>>> float('2,2')
2.2000000000000002
>>> float('2.2')
2.2000000000000002

I tried setting my PDA to the Italian locale and I can see the problem that 
you describe. The bug is that Windows CE (or at least Pocket PC 2003) does 
not provide a setlocale() function (so of course strtod() doesn't support 
locales), but in the PythonCE code we are providing a fake setlocale() and 
localeconv() which default to returning the user default locale settings.

The only solution I can see is to change localeconv() and setlocale() to 
always return the "C" locale settings. Do you agree? To get working locales 
we would need to rewrite strtod() and many other functions to take into 
account the current locale, so that is not really feasible.

> Except for this Python 2.4 rocks, and it loads even faster. really good 
> job.
>
> (There is also one other minor addition that I would appreciate: adding
> Cut/Copy/Paste on the menu near Beak/Exit/...,  with the stilus it's a
> log way around to get to Ctrl+C/X/V ...)

Could you please submit this to the SourceForge feature request tracker so 
that it isn't forgotten?

http://sourceforge.net/tracker/?group_id=104228&atid=637343

Luke

>
> I'll  try to recompile it this weekend, so that I can  port sqlite (and
> maybe even wxPython, 4Suite and IPython) to pyce 2.4.3
>
>       Giovanni


More information about the PythonCE mailing list