diff options
author | Eric Smith <eric@trueblade.com> | 2009-10-16 14:26:36 (GMT) |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2009-10-16 14:26:36 (GMT) |
commit | b327258d4fa85ee7e30bfb4377230018857d0eaf (patch) | |
tree | 48e136cd2baa0207c078e009b1d568be48cb8456 /Objects/floatobject.c | |
parent | 03d5c346c05915816a5e382545b3b9cc547c45fd (diff) | |
download | cpython-b327258d4fa85ee7e30bfb4377230018857d0eaf.zip cpython-b327258d4fa85ee7e30bfb4377230018857d0eaf.tar.gz cpython-b327258d4fa85ee7e30bfb4377230018857d0eaf.tar.bz2 |
Removed usage of unsafe PyFloat_AsString.
Diffstat (limited to 'Objects/floatobject.c')
-rw-r--r-- | Objects/floatobject.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 73d6a1f..745fe54 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -2012,15 +2012,21 @@ PyFloat_Fini(void) i++, p++) { if (PyFloat_CheckExact(p) && Py_REFCNT(p) != 0) { - char buf[100]; - PyFloat_AsString(buf, p); - /* XXX(twouters) cast refcount to - long until %zd is universally - available - */ - fprintf(stderr, + char *buf = PyOS_double_to_string( + PyFloat_AS_DOUBLE(p), 'r', + 0, 0, NULL); + if (buf) { + /* XXX(twouters) cast + refcount to long + until %zd is + universally + available + */ + fprintf(stderr, "# <float at %p, refcnt=%ld, val=%s>\n", p, (long)Py_REFCNT(p), buf); + PyMem_Free(buf); + } } } list = list->next; |