This patch turns the Python API mismatch notice into a standard

Python warning which can be catched by means of the Python warning
framework.

It also adds two new APIs which hopefully make it easier for Python
to switch to buffer overflow safe [v]snprintf() APIs for error
reporting et al. The two new APIs are PyOS_snprintf() and
PyOS_vsnprintf() and work just like the standard ones in many
C libs. On platforms which have snprintf(), the native APIs are used,
on all other an emulation with snprintf() tries to do its best.
This commit is contained in:
Marc-André Lemburg 2001-07-31 13:24:44 +00:00
parent b9d07b5a8b
commit e5006ebc9d
4 changed files with 124 additions and 5 deletions

View file

@ -106,6 +106,22 @@ extern DL_IMPORT(void) PyErr_SetInterrupt(void);
extern DL_IMPORT(void) PyErr_SyntaxLocation(char *, int);
extern DL_IMPORT(PyObject *) PyErr_ProgramText(char *, int);
/* These APIs aren't really part of the error implementation, but
often needed to format error messages; the native C lib APIs are
not available on all platforms, which is why we provide emulations
for those platforms in Python/mysnprintf.c */
#if defined(MS_WIN32) && !defined(HAVE_SNPRINTF)
# define HAVE_SNPRINTF
# define snprintf _snprintf
# define vsnprintf _vsnprintf
#endif
#ifndef HAVE_SNPRINTF
extern DL_IMPORT(int) PyOS_snprintf(char *str, size_t size, const char *format, ...);
extern DL_IMPORT(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va);
#else
# define PyOS_vsnprintf vsnprintf
# define PyOS_snprintf snprintf
#endif
#ifdef __cplusplus
}