[ python-Bugs-1391872 ] floating point literals don't work in non-US locale in 2.5

SourceForge.net noreply at sourceforge.net
Thu Dec 29 19:52:56 CET 2005


Bugs item #1391872, was opened at 2005-12-28 12:01
Message generated for change (Comment added) made by effbot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1391872&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
Status: Open
Resolution: None
Priority: 9
Submitted By: Fredrik Lundh (effbot)
>Assigned to: Fredrik Lundh (effbot)
Summary: floating point literals don't work in non-US locale in 2.5

Initial Comment:
According to reports on comp.lang.python, the current 
SVN trunk fails to handle floating point literals if 
the locale is changed:

>>> import locale 
>>> locale.setlocale(locale.LC_ALL, '') 
'German_Germany.1252' 
>>> 3.141592 
3.0 

This works just fine in 2.4.2.

See the later portions of the thread "build 
curiosities of svn head (on WinXP)" for more details:

http://groups.google.com/group/comp.lang.python/browse_
frm/thread/226584dd47047bb6/e609cb1a0d47e98f

----------------------------------------------------------------------

>Comment By: Fredrik Lundh (effbot)
Date: 2005-12-29 19:52

Message:
Logged In: YES 
user_id=38376

Looks good to me.  I'll check this in shortly.

----------------------------------------------------------------------

Comment By: Hye-Shik Chang (perky)
Date: 2005-12-29 09:22

Message:
Logged In: YES 
user_id=55188

The new patch tests it along with other locale-dependent 
tests on test__locale. How about this?

----------------------------------------------------------------------

Comment By: Fredrik Lundh (effbot)
Date: 2005-12-28 20:00

Message:
Logged In: YES 
user_id=38376

I'm not sure you can make too many assumptions about
the locale in the test suite, but I'm pretty sure that
it would be a good idea to let your "build robot" run
the test suite twice; once with the standard C locale,
and once with a non-US locale (e.g. sv_SE.utf8 which
does include some odd characters, different date and
money formats, and a decimal comma).

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2005-12-28 19:16

Message:
Logged In: YES 
user_id=33168

Wow, I thought for sure I broke it with my recent patch to remove support for 
hex floats.  But it looks like just an AST problem (which I can be blamed for 
too :-).  The patch looks fine, but could you add tests so this doesn't happen 
again.  Thanks!

I'll be back in a week and try to fix it then if no one gets back to it.

----------------------------------------------------------------------

Comment By: Hye-Shik Chang (perky)
Date: 2005-12-28 15:04

Message:
Logged In: YES 
user_id=55188

Okay. Here's a fix.

----------------------------------------------------------------------

Comment By: Hye-Shik Chang (perky)
Date: 2005-12-28 14:41

Message:
Logged In: YES 
user_id=55188

This looks like a bug introduced by AST import;
r39757 is okay but r39762 has such an error.

----------------------------------------------------------------------

Comment By: Fredrik Lundh (effbot)
Date: 2005-12-28 12:02

Message:
Logged In: YES 
user_id=38376

I just confirmed this on Unix:

$ export LANG=sv_SE.utf8
$ ./python
Python 2.5a0 (41806M, Dec 25 2005, 12:12:29)
[GCC 2.96 20000731 (Red Hat Linux 7.2 2.96-112.7.2)] on 
linux2
Type "help", "copyright", "credits" or "license" for more 
information.
>>> 3.14
3.1400000000000001
>>> import locale
>>> locale.setlocale(locale.LC_ALL, "")
'sv_SE.utf8'
>>> 3.14
3.0
>>>


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1391872&group_id=5470


More information about the Python-bugs-list mailing list