summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2007-06-05 19:50:53 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2007-06-05 19:50:53 (GMT)
commit233ccf289353edb5486304630ebb1755f87738ec (patch)
tree12827a472c9f4dc53ed48f0b129d5776a91f1980 /Objects
parent5b0443cf3ef5799cd34fc5975b3225ecd07233ef (diff)
downloadcpython-233ccf289353edb5486304630ebb1755f87738ec.zip
cpython-233ccf289353edb5486304630ebb1755f87738ec.tar.gz
cpython-233ccf289353edb5486304630ebb1755f87738ec.tar.bz2
Change int_oct() and int_hex() to return unicode objects.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/intobject.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/Objects/intobject.c b/Objects/intobject.c
index ab64f79..ad60a49 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -920,27 +920,23 @@ int_float(PyIntObject *v)
static PyObject *
int_oct(PyIntObject *v)
{
- char buf[100];
long x = v -> ob_ival;
if (x < 0)
- PyOS_snprintf(buf, sizeof(buf), "-0%lo", -x);
+ return PyUnicode_FromFormat("-0%lo", -x);
else if (x == 0)
- strcpy(buf, "0");
+ return PyUnicode_FromString("0");
else
- PyOS_snprintf(buf, sizeof(buf), "0%lo", x);
- return PyString_FromString(buf);
+ return PyUnicode_FromFormat("0%lo", x);
}
static PyObject *
int_hex(PyIntObject *v)
{
- char buf[100];
long x = v -> ob_ival;
if (x < 0)
- PyOS_snprintf(buf, sizeof(buf), "-0x%lx", -x);
+ return PyUnicode_FromFormat("-0x%lx", -x);
else
- PyOS_snprintf(buf, sizeof(buf), "0x%lx", x);
- return PyString_FromString(buf);
+ return PyUnicode_FromFormat("0x%lx", x);
}
static PyObject *