eric.smith
2008-07-19 00:33:23 UTC
Author: eric.smith
Date: Sat Jul 19 02:33:23 2008
New Revision: 65126
Log:
Merged revisions 65125 via svnmerge from
svn+ssh://pythondev at 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.
........
Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Lib/test/test_types.py
python/branches/py3k/Python/pystrtod.c
Modified: python/branches/py3k/Lib/test/test_types.py
==============================================================================
--- python/branches/py3k/Lib/test/test_types.py (original)
+++ python/branches/py3k/Lib/test/test_types.py Sat Jul 19 02:33:23 2008
@@ -497,6 +497,12 @@
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')
Modified: python/branches/py3k/Python/pystrtod.c
==============================================================================
--- python/branches/py3k/Python/pystrtod.c (original)
+++ python/branches/py3k/Python/pystrtod.c Sat Jul 19 02:33:23 2008
@@ -302,6 +302,10 @@
/* 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;
Date: Sat Jul 19 02:33:23 2008
New Revision: 65126
Log:
Merged revisions 65125 via svnmerge from
svn+ssh://pythondev at 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.
........
Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Lib/test/test_types.py
python/branches/py3k/Python/pystrtod.c
Modified: python/branches/py3k/Lib/test/test_types.py
==============================================================================
--- python/branches/py3k/Lib/test/test_types.py (original)
+++ python/branches/py3k/Lib/test/test_types.py Sat Jul 19 02:33:23 2008
@@ -497,6 +497,12 @@
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')
Modified: python/branches/py3k/Python/pystrtod.c
==============================================================================
--- python/branches/py3k/Python/pystrtod.c (original)
+++ python/branches/py3k/Python/pystrtod.c Sat Jul 19 02:33:23 2008
@@ -302,6 +302,10 @@
/* 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;