summaryrefslogtreecommitdiffstats
path: root/Python/errors.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-02-14 17:09:47 (GMT)
committerGuido van Rossum <guido@python.org>1997-02-14 17:09:47 (GMT)
commit1548bacb1406423111cff23cf167fe231b88f4bc (patch)
tree45933696ac4a66f8c9311e8f145721c6accfcad8 /Python/errors.c
parentbabacb03693471d614e6d9c1bac6f2ec6cc2bccd (diff)
downloadcpython-1548bacb1406423111cff23cf167fe231b88f4bc.zip
cpython-1548bacb1406423111cff23cf167fe231b88f4bc.tar.gz
cpython-1548bacb1406423111cff23cf167fe231b88f4bc.tar.bz2
Added convenience function PyErr_Format(exception, formatstring, ...) -> NULL.
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/Python/errors.c b/Python/errors.c
index a1ab4b8..b011acc 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;
+}