diff Python/errors.c @ 5105:00fd6857f76b legacy-trunk

Added convenience function PyErr_Format(exception, formatstring, ...) -> NULL.
author Guido van Rossum <guido@python.org>
date Fri, 14 Feb 1997 17:09:47 +0000
parents df81856db58c
children ca6388bcc05a
line wrap: on
line diff
--- a/Python/errors.c	Fri Feb 14 16:44:04 1997 +0000
+++ b/Python/errors.c	Fri Feb 14 17:09:47 1997 +0000
@@ -203,3 +203,30 @@
 {
 	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;
+}