Kaydet (Commit) 1548bacb authored tarafından Guido van Rossum's avatar Guido van Rossum

Added convenience function PyErr_Format(exception, formatstring, ...) -> NULL.

üst babacb03
...@@ -203,3 +203,30 @@ err_badcall() ...@@ -203,3 +203,30 @@ err_badcall()
{ {
err_setstr(SystemError, "bad argument to internal function"); 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment