summaryrefslogtreecommitdiffstats
path: root/Objects/stringobject.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2007-08-14 21:57:32 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2007-08-14 21:57:32 (GMT)
commitff398c6f957fcd0e55aa57c0eaa5c1d24c5bc2f1 (patch)
tree1fb5dc2dfb074e6b0d10c167b3ab5deeab2ef4f3 /Objects/stringobject.c
parent3eed76522389d55248a71aa8c83203aa3ae0873b (diff)
downloadcpython-ff398c6f957fcd0e55aa57c0eaa5c1d24c5bc2f1.zip
cpython-ff398c6f957fcd0e55aa57c0eaa5c1d24c5bc2f1.tar.gz
cpython-ff398c6f957fcd0e55aa57c0eaa5c1d24c5bc2f1.tar.bz2
Format bools properly in %d.
Diffstat (limited to 'Objects/stringobject.c')
-rw-r--r--Objects/stringobject.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 7a35974..b1d711d 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;