summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2007-06-20 15:11:12 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2007-06-20 15:11:12 (GMT)
commit63a28be01693584afcadc39ca650efc5fa8f2880 (patch)
tree31bad7b65df8c3e68cd2f168c2f6d12fdc496a05 /Objects
parent4ee631e756fa55b3e766b7580e30c2492aae802a (diff)
downloadcpython-63a28be01693584afcadc39ca650efc5fa8f2880.zip
cpython-63a28be01693584afcadc39ca650efc5fa8f2880.tar.gz
cpython-63a28be01693584afcadc39ca650efc5fa8f2880.tar.bz2
Silence GCC warning about uninitialzed variable.
Simplify formatlong() (by using PyUnicode_FromStringAndSize()).
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 7310ebd..3777991 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -540,7 +540,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
va_list count;
Py_ssize_t callcount = 0;
PyObject **callresults = NULL;
- PyObject **callresult;
+ PyObject **callresult = NULL;
Py_ssize_t n = 0;
int width = 0;
int precision = 0;
@@ -7955,23 +7955,16 @@ static PyObject*
formatlong(PyObject *val, int flags, int prec, int type)
{
char *buf;
- int i, len;
+ int len;
PyObject *str; /* temporary string object. */
- PyUnicodeObject *result;
+ PyObject *result;
str = _PyString_FormatLong(val, flags, prec, type, &buf, &len);
if (!str)
return NULL;
- result = _PyUnicode_New(len);
- if (!result) {
- Py_DECREF(str);
- return NULL;
- }
- for (i = 0; i < len; i++)
- result->str[i] = buf[i];
- result->str[len] = 0;
+ result = PyUnicode_FromStringAndSize(buf, len);
Py_DECREF(str);
- return (PyObject*)result;
+ return result;
}
static int