mirror of
https://github.com/python/cpython.git
synced 2025-10-21 06:02:21 +00:00
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:
parent
16c018d2d2
commit
dadace004b
2 changed files with 159 additions and 0 deletions
|
@ -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 *);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue