]> granicus.if.org Git - python/commitdiff
Change int_oct() and int_hex() to return unicode objects.
authorWalter Dörwald <walter@livinglogic.de>
Tue, 5 Jun 2007 19:50:53 +0000 (19:50 +0000)
committerWalter Dörwald <walter@livinglogic.de>
Tue, 5 Jun 2007 19:50:53 +0000 (19:50 +0000)
Objects/intobject.c

index ab64f79e0992c25cb5b5f2d9812973ba24e46e55..ad60a49b2d9685aa58cf2921b320780e67b670b1 100644 (file)
@@ -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 *