mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
Silence GCC warning about uninitialzed variable.
Simplify formatlong() (by using PyUnicode_FromStringAndSize()).
This commit is contained in:
parent
4ee631e756
commit
63a28be016
1 changed files with 5 additions and 12 deletions
|
@ -540,7 +540,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
|
||||||
va_list count;
|
va_list count;
|
||||||
Py_ssize_t callcount = 0;
|
Py_ssize_t callcount = 0;
|
||||||
PyObject **callresults = NULL;
|
PyObject **callresults = NULL;
|
||||||
PyObject **callresult;
|
PyObject **callresult = NULL;
|
||||||
Py_ssize_t n = 0;
|
Py_ssize_t n = 0;
|
||||||
int width = 0;
|
int width = 0;
|
||||||
int precision = 0;
|
int precision = 0;
|
||||||
|
@ -7955,23 +7955,16 @@ static PyObject*
|
||||||
formatlong(PyObject *val, int flags, int prec, int type)
|
formatlong(PyObject *val, int flags, int prec, int type)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
int i, len;
|
int len;
|
||||||
PyObject *str; /* temporary string object. */
|
PyObject *str; /* temporary string object. */
|
||||||
PyUnicodeObject *result;
|
PyObject *result;
|
||||||
|
|
||||||
str = _PyString_FormatLong(val, flags, prec, type, &buf, &len);
|
str = _PyString_FormatLong(val, flags, prec, type, &buf, &len);
|
||||||
if (!str)
|
if (!str)
|
||||||
return NULL;
|
return NULL;
|
||||||
result = _PyUnicode_New(len);
|
result = PyUnicode_FromStringAndSize(buf, len);
|
||||||
if (!result) {
|
|
||||||
Py_DECREF(str);
|
Py_DECREF(str);
|
||||||
return NULL;
|
return result;
|
||||||
}
|
|
||||||
for (i = 0; i < len; i++)
|
|
||||||
result->str[i] = buf[i];
|
|
||||||
result->str[len] = 0;
|
|
||||||
Py_DECREF(str);
|
|
||||||
return (PyObject*)result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue