[PythonCE] Python 2.4.3 for Windows CE / ARM

Giovanni Petrucciani gpetruc at gmail.com
Sat Apr 8 19:57:40 CEST 2006

Luke Dunstan wrote:
> 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):
Yes, I found that disabling the "de-localization" code in pystrtod.c,
and in fact now I just
replaced "if (decimalseparator[0] != '.' ...)" with "if (0)" and
everything works fine (using '.' and not ',')
> 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.
I think it's fine, most of the people won't be surprized to see that
float('8.4') is ok and float('8,4') is not
even if in their locale the "," is used instead of the "." ...


More information about the PythonCE mailing list