From ff398c6f957fcd0e55aa57c0eaa5c1d24c5bc2f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Tue, 14 Aug 2007 21:57:32 +0000 Subject: Format bools properly in %d. --- Objects/stringobject.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Objects/stringobject.c') diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 7a35974bc2..b1d711d3f7 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -4144,11 +4144,14 @@ _PyString_FormatLong(PyObject *val, int flags, int prec, int type, return NULL; } - switch (type) { case 'd': case 'u': - result = Py_Type(val)->tp_str(val); + /* Special-case boolean: we want 0/1 */ + if (PyBool_Check(val)) + result = PyNumber_ToBase(val, 10); + else + result = Py_Type(val)->tp_str(val); break; case 'o': numnondigits = 2; -- cgit v1.2.1