[Python-bugs-list] [ python-Bugs-783348 ] UNIX-locale and repr()
SourceForge.net
noreply@sourceforge.net
Tue, 05 Aug 2003 00:55:39 -0700
Bugs item #783348, was opened at 2003-08-05 09:55
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=783348&group_id=5470
Category: None
Group: Python 2.1.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Joerg Linnenkohl (jolinnen)
Assigned to: Nobody/Anonymous (nobody)
Summary: UNIX-locale and repr()
Initial Comment:
Hi,
please look at this code snippet:
#!/usr/bin/python
import sys
import os
import random
import locale
locale.setlocale(locale.LC_ALL, 'de_DE@euro')
dp = locale.localeconv().get('decimal_point', '.')
# print "--->",locale.localeconv()
print "--->",dp
a = random.random()
b = repr(a)
print b
with this output :
---> ,
0.24851180874790457
I expect that the output of b must be "0,24851180874790457"
with a "," as a decimal point corresponding to the locale.
But for floating point numbers repr() always delivers the "."
as decimal point for the german locale.
The real problem occurs in the email package
(http://mimelib.sourceforge.net/) in the method :
def _make_boundary(text=None):
# Craft a random boundary. If text is given, ensure that the
chosen
# boundary doesn't appear in the text.
dp = locale.localeconv().get('decimal_point', '.')
boundary = ('=' * 15) + repr(random.random()).split(dp)[1] +
'=='
for the german locale (error 'listindex out of range') on
repr(random.random()).split(dp)[1].
Kind regards
Jörg Linnenkohl
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=783348&group_id=5470