summaryrefslogtreecommitdiff
path: root/Python/dtoa.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/dtoa.c')
-rw-r--r--Python/dtoa.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Python/dtoa.c b/Python/dtoa.c
index 822adc6129..e629b29642 100644
--- a/Python/dtoa.c
+++ b/Python/dtoa.c
@@ -64,6 +64,9 @@
* 7. _Py_dg_strtod has been modified so that it doesn't accept strings with
* leading whitespace.
*
+ * 8. A corner case where _Py_dg_dtoa didn't strip trailing zeros has been
+ * fixed. (bugs.python.org/issue40780)
+ *
***************************************************************/
/* Please send bug reports for the original dtoa.c code to David M. Gay (dmg
@@ -2563,6 +2566,14 @@ _Py_dg_dtoa(double dd, int mode, int ndigits,
}
++*s++;
}
+ else {
+ /* Strip trailing zeros. This branch was missing from the
+ original dtoa.c, leading to surplus trailing zeros in
+ some cases. See bugs.python.org/issue40780. */
+ while (s > s0 && s[-1] == '0') {
+ --s;
+ }
+ }
break;
}
}