Skip to content

Commit

Permalink
Merged revisions 65125 via svnmerge from
Browse files Browse the repository at this point in the history
svn+ssh://[email protected]/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.
........
  • Loading branch information
ericvsmith committed Jul 19, 2008
1 parent 32480b0 commit 2ad79e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Lib/test/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,12 @@ def test(f, format_spec, result):
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')
Expand Down
4 changes: 4 additions & 0 deletions Python/pystrtod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 2ad79e8

Please sign in to comment.