]> granicus.if.org Git - python/commitdiff
Merged revisions 65125 via svnmerge from
authorEric Smith <eric@trueblade.com>
Sat, 19 Jul 2008 00:33:23 +0000 (00:33 +0000)
committerEric Smith <eric@trueblade.com>
Sat, 19 Jul 2008 00:33:23 +0000 (00:33 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r65125 | eric.smith | 2008-07-18 20:24:05 -0400 (Fri, 18 Jul 2008) | 1 line

  Fix issue 3411: default float format spec fails on negative numbers.
........

Lib/test/test_types.py
Python/pystrtod.c

index 1b8e6054d7f5a8a45efe2aeea55fb639d3670308..c200e07b2a346e485f26a57d53e190ed032c142d 100644 (file)
@@ -497,6 +497,12 @@ class TypesTests(unittest.TestCase):
         test(0.01, '', '0.01')
         test(0.01, 'g', '0.01')
 
+        # test for issue 3411
+        test(1.23, '1', '1.23')
+        test(-1.23, '1', '-1.23')
+        test(1.23, '1g', '1.23')
+        test(-1.23, '1g', '-1.23')
+
         test( 1.0, ' g', ' 1')
         test(-1.0, ' g', '-1')
         test( 1.0, '+g', '+1')
index 5a96b58e15fc459a9e28098176e0bf03b10648cc..b3738528dbfe7f1c108a892beae449052898e985 100644 (file)
@@ -302,6 +302,10 @@ ensure_decimal_point(char* buffer, size_t buf_size)
 
        /* search for the first non-digit character */
        char *p = buffer;
+       if (*p == '-' || *p == '+')
+               /* Skip leading sign, if present.  I think this could only
+                  ever be '-', but it can't hurt to check for both. */
+               ++p;
        while (*p && isdigit(Py_CHARMASK(*p)))
                ++p;