[3.9] bpo-40780: Fix failure of _Py_dg_dtoa to remove trailing zeros (GH-20435) by miss-islington · Pull Request #20514 · python/cpython

@mdickinson @miss-islington

…nGH-20435)

* Fix failure of _Py_dg_dtoa to remove trailing zeros

* Add regression test and news entry

* Add explanation about why it's safe to strip trailing zeros

* Make code safer, clean up comments, add change note at top of file

* Nitpick: avoid implicit int-to-float conversion in tests
(cherry picked from commit 895c9c1)

Co-authored-by: Mark Dickinson <mdickinson@enthought.com>