Kaydet (Commit) f032a002 authored tarafından Eric Smith's avatar Eric Smith

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

üst 1e8fba72
......@@ -570,6 +570,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')
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment