diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2014-09-30 19:16:27 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2014-09-30 19:16:27 (GMT) |
commit | 0676a406bf9435a59eaca1a54fa582b0b6b79b9f (patch) | |
tree | 8e742ce5dc38872dfadfac8b6c673ebacb1c3403 /Python/errors.c | |
parent | 63860e5407e9ac1251e0698fb2d208a1da54bd3c (diff) | |
download | cpython-0676a406bf9435a59eaca1a54fa582b0b6b79b9f.zip cpython-0676a406bf9435a59eaca1a54fa582b0b6b79b9f.tar.gz cpython-0676a406bf9435a59eaca1a54fa582b0b6b79b9f.tar.bz2 |
Issue #18711: Add a new `PyErr_FormatV` function, similar to `PyErr_Format` but accepting a `va_list` argument.
Diffstat (limited to 'Python/errors.c')
-rw-r--r-- | Python/errors.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/Python/errors.c b/Python/errors.c index 996292a..fd55142 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -749,19 +749,11 @@ PyErr_BadInternalCall(void) #define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__) - PyObject * -PyErr_Format(PyObject *exception, const char *format, ...) +PyErr_FormatV(PyObject *exception, const char *format, va_list vargs) { - va_list vargs; PyObject* string; -#ifdef HAVE_STDARG_PROTOTYPES - va_start(vargs, format); -#else - va_start(vargs); -#endif - #ifdef Py_DEBUG /* in debug mode, PyEval_EvalFrameEx() fails with an assertion error if an exception is set when it is called */ @@ -771,11 +763,24 @@ PyErr_Format(PyObject *exception, const char *format, ...) string = PyUnicode_FromFormatV(format, vargs); PyErr_SetObject(exception, string); Py_XDECREF(string); - va_end(vargs); return NULL; } +PyObject * +PyErr_Format(PyObject *exception, const char *format, ...) +{ + va_list vargs; +#ifdef HAVE_STDARG_PROTOTYPES + va_start(vargs, format); +#else + va_start(vargs); +#endif + PyErr_FormatV(exception, format, vargs); + va_end(vargs); + return NULL; +} + PyObject * PyErr_NewException(const char *name, PyObject *base, PyObject *dict) |