summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2001-08-27 03:11:09 (GMT)
committerBarry Warsaw <barry@python.org>2001-08-27 03:11:09 (GMT)
commit7c47beb860fcea2029850f1036fe1be216aab78e (patch)
treef8f5d5120237de1c7264d9d33d1bedc8ee70be40 /Objects
parent5a6fdcd3718927109592c6df692fe24a8fdaee31 (diff)
downloadcpython-7c47beb860fcea2029850f1036fe1be216aab78e.zip
cpython-7c47beb860fcea2029850f1036fe1be216aab78e.tar.gz
cpython-7c47beb860fcea2029850f1036fe1be216aab78e.tar.bz2
Two improvements suggested by Greg Stein:
PyString_FromFormatV(): In the final resize at the end, we can use PyString_AS_STRING() since we know the object is a string and can avoid the typechecking. PyString_FromFormat(): GS sez: "For safety/propriety, you should call va_end() on the vargs variable."
Diffstat (limited to 'Objects')
-rw-r--r--Objects/stringobject.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 9ea32a2..1332881 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -292,13 +292,14 @@ PyString_FromFormatV(const char *format, va_list vargs)
}
end:
- _PyString_Resize(&string, s - PyString_AsString(string));
+ _PyString_Resize(&string, s - PyString_AS_STRING(string));
return string;
}
PyObject *
PyString_FromFormat(const char *format, ...)
{
+ PyObject* ret;
va_list vargs;
#ifdef HAVE_STDARG_PROTOTYPES
@@ -306,7 +307,9 @@ PyString_FromFormat(const char *format, ...)
#else
va_start(vargs);
#endif
- return PyString_FromFormatV(format, vargs);
+ ret = PyString_FromFormatV(format, vargs);
+ va_end(vargs);
+ return ret;
}