PyString_FromFormat() and PyString_FromFormatV(): Largely ripped from
PyErr_Format() these new C API methods can be used instead of
sprintf()'s into hardcoded char* buffers. This allows us to fix
many situation where long package, module, or class names get
truncated in reprs.
PyString_FromFormat() is the varargs variety.
PyString_FromFormatV() is the va_list variety
Original PyErr_Format() code was modified to allow %p and %ld
expansions.
Many reprs were converted to this, checkins coming soo. Not
changed: complex_repr(), float_repr(), float_print(), float_str(),
int_repr(). There may be other candidates not yet converted.
Closes patch #454743.
diff --git a/Include/stringobject.h b/Include/stringobject.h
index 96f371e..2d9ed2d 100644
--- a/Include/stringobject.h
+++ b/Include/stringobject.h
@@ -7,6 +7,8 @@
extern "C" {
#endif
+#include <stdarg.h>
+
/*
Type PyStringObject represents a character string. An extra zero byte is
reserved at the end to ensure it is zero-terminated, but a size is
@@ -53,6 +55,8 @@
extern DL_IMPORT(PyObject *) PyString_FromStringAndSize(const char *, int);
extern DL_IMPORT(PyObject *) PyString_FromString(const char *);
+extern DL_IMPORT(PyObject *) PyString_FromFormatV(const char*, va_list);
+extern DL_IMPORT(PyObject *) PyString_FromFormat(const char*, ...);
extern DL_IMPORT(int) PyString_Size(PyObject *);
extern DL_IMPORT(char *) PyString_AsString(PyObject *);
extern DL_IMPORT(void) PyString_Concat(PyObject **, PyObject *);