comparison 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
comparison
equal deleted inserted replaced
5104:4109a171c901 5105:00fd6857f76b
201 void 201 void
202 err_badcall() 202 err_badcall()
203 { 203 {
204 err_setstr(SystemError, "bad argument to internal function"); 204 err_setstr(SystemError, "bad argument to internal function");
205 } 205 }
206
207
208 #ifdef HAVE_STDARG_PROTOTYPES
209 PyObject *
210 PyErr_Format(PyObject *exception, const char *format, ...)
211 #else
212 PyObject *
213 PyErr_Format(exception, format, va_alist)
214 PyObject *exception;
215 const char *format;
216 va_dcl
217 #endif
218 {
219 va_list vargs;
220 char buffer[500]; /* Caller is responsible for limiting the format */
221 PyObject *s;
222
223 #ifdef HAVE_STDARG_PROTOTYPES
224 va_start(vargs, format);
225 #else
226 va_start(vargs);
227 #endif
228
229 vsprintf(buffer, format, vargs);
230 PyErr_SetString(exception, buffer);
231 return NULL;
232 }