[Python-checkins] r65125 - in python/trunk: Lib/test/test_types.py Python/pystrtod.c
eric.smith
python-checkins at python.org
Sat Jul 19 02:24:05 CEST 2008
Author: eric.smith
Date: Sat Jul 19 02:24:05 2008
New Revision: 65125
Log:
Fix issue 3411: default float format spec fails on negative numbers.
Modified:
python/trunk/Lib/test/test_types.py
python/trunk/Python/pystrtod.c
Modified: python/trunk/Lib/test/test_types.py
==============================================================================
--- python/trunk/Lib/test/test_types.py (original)
+++ python/trunk/Lib/test/test_types.py Sat Jul 19 02:24:05 2008
@@ -570,6 +570,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/trunk/Python/pystrtod.c
==============================================================================
--- python/trunk/Python/pystrtod.c (original)
+++ python/trunk/Python/pystrtod.c Sat Jul 19 02:24:05 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;
More information about the Python-checkins
mailing list