diff options
author | Marc-André Lemburg <mal@egenix.com> | 2001-07-31 13:24:44 (GMT) |
---|---|---|
committer | Marc-André Lemburg <mal@egenix.com> | 2001-07-31 13:24:44 (GMT) |
commit | e5006ebc9d0618bc500afebfa1e21b6aae2a22e3 (patch) | |
tree | 021cf814e21772f87b22cac30a4aeada787085bc /Include | |
parent | b9d07b5a8b8b70268ffa520895e7843ab594a486 (diff) | |
download | cpython-e5006ebc9d0618bc500afebfa1e21b6aae2a22e3.zip cpython-e5006ebc9d0618bc500afebfa1e21b6aae2a22e3.tar.gz cpython-e5006ebc9d0618bc500afebfa1e21b6aae2a22e3.tar.bz2 |
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.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/pyerrors.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Include/pyerrors.h b/Include/pyerrors.h index 3c57e2f..bfc36ae 100644 --- a/Include/pyerrors.h +++ b/Include/pyerrors.h @@ -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 } |