From: Guido van Rossum Date: Fri, 14 Feb 1997 17:09:47 +0000 (+0000) Subject: Added convenience function PyErr_Format(exception, formatstring, ...) -> NULL. X-Git-Tag: v1.5a1~371 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1548bacb1406423111cff23cf167fe231b88f4bc;p=thirdparty%2FPython%2Fcpython.git Added convenience function PyErr_Format(exception, formatstring, ...) -> NULL. --- diff --git a/Python/errors.c b/Python/errors.c index a1ab4b873cf3..b011acc44166 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -203,3 +203,30 @@ err_badcall() { err_setstr(SystemError, "bad argument to internal function"); } + + +#ifdef HAVE_STDARG_PROTOTYPES +PyObject * +PyErr_Format(PyObject *exception, const char *format, ...) +#else +PyObject * +PyErr_Format(exception, format, va_alist) + PyObject *exception; + const char *format; + va_dcl +#endif +{ + va_list vargs; + char buffer[500]; /* Caller is responsible for limiting the format */ + PyObject *s; + +#ifdef HAVE_STDARG_PROTOTYPES + va_start(vargs, format); +#else + va_start(vargs); +#endif + + vsprintf(buffer, format, vargs); + PyErr_SetString(exception, buffer); + return NULL; +}