mirror of
https://github.com/python/cpython.git
synced 2025-12-11 11:31:05 +00:00
Change int_oct() and int_hex() to return unicode objects.
This commit is contained in:
parent
5b0443cf3e
commit
233ccf2893
1 changed files with 5 additions and 9 deletions
|
|
@ -920,27 +920,23 @@ int_float(PyIntObject *v)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_oct(PyIntObject *v)
|
int_oct(PyIntObject *v)
|
||||||
{
|
{
|
||||||
char buf[100];
|
|
||||||
long x = v -> ob_ival;
|
long x = v -> ob_ival;
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
PyOS_snprintf(buf, sizeof(buf), "-0%lo", -x);
|
return PyUnicode_FromFormat("-0%lo", -x);
|
||||||
else if (x == 0)
|
else if (x == 0)
|
||||||
strcpy(buf, "0");
|
return PyUnicode_FromString("0");
|
||||||
else
|
else
|
||||||
PyOS_snprintf(buf, sizeof(buf), "0%lo", x);
|
return PyUnicode_FromFormat("0%lo", x);
|
||||||
return PyString_FromString(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_hex(PyIntObject *v)
|
int_hex(PyIntObject *v)
|
||||||
{
|
{
|
||||||
char buf[100];
|
|
||||||
long x = v -> ob_ival;
|
long x = v -> ob_ival;
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
PyOS_snprintf(buf, sizeof(buf), "-0x%lx", -x);
|
return PyUnicode_FromFormat("-0x%lx", -x);
|
||||||
else
|
else
|
||||||
PyOS_snprintf(buf, sizeof(buf), "0x%lx", x);
|
return PyUnicode_FromFormat("0x%lx", x);
|
||||||
return PyString_FromString(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue