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.
This commit is contained in:
Barry Warsaw 2001-08-24 18:32:06 +00:00
parent 16c018d2d2
commit dadace004b
2 changed files with 159 additions and 0 deletions

View file

@ -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(PyTypeObject) PyString_Type;
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 *);