[Checkins] SVN: zope.i18n/trunk/ - Bug: There was a bug in the parser that if no decimal place is given

Stephan Richter srichter at cosmos.phy.tufts.edu
Thu Jun 28 15:57:01 EDT 2007


Log message for revision 77188:
  - Bug: There was a bug in the parser that if no decimal place is given
    you still had to type the decimal symbol. Corrected this problem (one
    character ;-) and provided a test.
  
  

Changed:
  U   zope.i18n/trunk/CHANGES.txt
  U   zope.i18n/trunk/src/zope/i18n/format.py
  U   zope.i18n/trunk/src/zope/i18n/tests/test_formats.py

-=-
Modified: zope.i18n/trunk/CHANGES.txt
===================================================================
--- zope.i18n/trunk/CHANGES.txt	2007-06-28 19:53:17 UTC (rev 77187)
+++ zope.i18n/trunk/CHANGES.txt	2007-06-28 19:57:01 UTC (rev 77188)
@@ -1,19 +1,27 @@
 zope.i18n package changelog
 ===========================
 
-After 3.4.0b2
+After 3.4.0b3
 -------------
 
+3.4.0b3 - (6/28/2007)
+---------------------
+
+- Bug: There was a bug in the parser that if no decimal place is given 
+  you still had to type the decimal symbol. Corrected this problem (one 
+  character ;-) and provided a test.
+
 3.4.0b2 - (6/25/2007)
 ---------------------
 
-- Added ability to change the output type when parsing a number.
+- Feature: Added ability to change the output type when parsing a 
+  number.
 
 3.4.0b1
 -------
 
-- Fixed dependency on zope.security to require a version that does not have
-  the hidden dependency on zope.testing.
+- Bug: Fixed dependency on ``zope.security`` to require a version that 
+  does not have the hidden dependency on ``zope.testing``.
 
 
 Note: Releases between 3.2.0 and 3.4.0b1 were not tracked as individual
@@ -40,5 +48,5 @@
 3.0.0 - 2004/11/07
 ------------------
 
-- Corresponds to the verison of the zope.i18n package shipped as part of the
-  Zope X3.0.0 release.
+- Corresponds to the version of the zope.i18n package shipped as part of 
+  the Zope X3.0.0 release.

Modified: zope.i18n/trunk/src/zope/i18n/format.py
===================================================================
--- zope.i18n/trunk/src/zope/i18n/format.py	2007-06-28 19:53:17 UTC (rev 77187)
+++ zope.i18n/trunk/src/zope/i18n/format.py	2007-06-28 19:57:01 UTC (rev 77188)
@@ -264,7 +264,7 @@
             if bin_pattern[sign][FRACTION]:
                 max_precision = len(bin_pattern[sign][FRACTION])
                 min_precision = bin_pattern[sign][FRACTION].count('0')
-                regex += '['+self.symbols['decimal']+']'
+                regex += '['+self.symbols['decimal']+']?'
                 regex += '[0-9]{%i,%i}' %(min_precision, max_precision)
             if bin_pattern[sign][EXPONENTIAL] != '':
                 regex += self.symbols['exponential']

Modified: zope.i18n/trunk/src/zope/i18n/tests/test_formats.py
===================================================================
--- zope.i18n/trunk/src/zope/i18n/tests/test_formats.py	2007-06-28 19:53:17 UTC (rev 77187)
+++ zope.i18n/trunk/src/zope/i18n/tests/test_formats.py	2007-06-28 19:57:01 UTC (rev 77188)
@@ -892,6 +892,14 @@
         self.assertEqual(self.format.parse('23341.020', '###0.000#'),
                          23341.02)
 
+    def testParseDecimalWithOptionalDecimalDigits(self):
+        self.assertEqual(self.format.parse('23341.02', '###0.##'),
+                         23341.02)
+        self.assertEqual(self.format.parse('23341', '###0.#'),
+                         23341.0)
+        self.assertEqual(self.format.parse('23341.', '###0.#'),
+                         23341.0)
+
     def testParseScientificDecimal(self):
         self.assertEqual(self.format.parse('2.334102E04', '0.00####E00'),
                          23341.02)



More information about the Checkins mailing list