[issue25543] locale.atof keep '.' even if not part of the localeconv

2015-11-06 Thread Terry J. Reedy
Terry J. Reedy added the comment: I much prefer a new argument, 'strict=False', to a new, near-duplicate function. locale.atof('2.500,5') should raise. The only question is what should be displayed as the invalid literal: the original or the converted. It seems to me that delocalize should r

[issue25543] locale.atof keep '.' even if not part of the localeconv

2015-11-03 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: @eric.smith maybe we can add a new strict function. -- nosy: +matrixise ___ Python tracker ___ ___

[issue25543] locale.atof keep '.' even if not part of the localeconv

2015-11-03 Thread Eric V. Smith
Eric V. Smith added the comment: That's an unfortunate implementation choice. I agree we probably can't break locale.atof, but how about adding another function with a better implementation, that's strictly locale-aware? -- nosy: +eric.smith ___ Pyt

[issue25543] locale.atof keep '.' even if not part of the localeconv

2015-11-03 Thread Cédric Krier
Cédric Krier added the comment: But you can have some strange behaviour: >>> import locale >>> locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8') 'fr_FR.UTF-8' >>> locale.atof('2.500,5') Traceback (most recent call last): File "", line 1, in File "/usr/lib64/python2.7/locale.py", line 316, in a

[issue25543] locale.atof keep '.' even if not part of the localeconv

2015-11-03 Thread STINNER Victor
STINNER Victor added the comment: locale.atof() is implemented as float(locale.delocalize(string)). locale.delocalize() replaces the locale numeric dot with ".": >>> locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8') 'fr_FR.UTF-8' >>> locale.delocalize("1,2") '1.2' >>> locale.localeconv()['decimal_

[issue25543] locale.atof keep '.' even if not part of the localeconv

2015-11-03 Thread Cédric Krier
Cédric Krier added the comment: Example: >>> import locale >>> locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8') 'fr_FR.UTF-8' >>> locale.atof('2.5') 2.5 >>> locale.atof('2,5') 2.5 -- ___ Python tracker _

[issue25543] locale.atof keep '.' even if not part of the localeconv

2015-11-03 Thread Cédric Krier
New submission from Cédric Krier: If a value containing '.' is passed to locale.atof, but '.' is not the locale decimal_point (and not the thousands_sep), it is anyway parsed as the decimal_point. For me, it should raise a ValueError -- components: Library (Lib) messages: 253989 nosy: