[Zope3-dev] Bugfix on i18n parsing
Sven Schomaker
Sven.Schomaker at linie-m.de
Mon May 23 05:15:00 EDT 2005
Hi all,
got a tiny fix for i18n number parsing. Did not work
for e.g. the german locale so fixed the bug. Maybe
someone wants to check it in if there is no mistake
in my bug fix (if I'm not entirely mistaken and there
is actually a bug in the code).
--- format.py
+++ format.py
@@ -277,9 +277,10 @@
type = int
if self.symbols['decimal'] in num_str:
type = float
+ num_str = num_str.replace(self.symbols['decimal'], '.')
if self.symbols['exponential'] in num_str:
type = float
- num_str.replace(self.symbols['exponential'], 'E')
+ num_str = num_str.replace(self.symbols['exponential'], 'E')
return sign*type(num_str)
def _format_integer(self, integer, pattern):
Description:
1. string replacement does not perform in-place modification of
the instance but returns a copy of the string with the replacement
applied.
2. float constructor does not accept locale specific fraction delimiter
so we need to replace it by the standard '.' to get the string parsed
correctly.
Greetings
Sven Schomaker
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope3-dev/attachments/20050523/8a354845/attachment.htm
More information about the Zope3-dev
mailing list