Cleanup call_method() and call_maybe()

Issue #27128. Move va_start/va_end around Py_VaBuildValue().
This commit is contained in:
Victor Stinner 2016-08-19 18:01:41 +02:00
parent 56142c701b
commit 94463c980e
1 changed files with 12 additions and 14 deletions

View File

@ -1425,23 +1425,22 @@ call_method(PyObject *o, _Py_Identifier *nameid, const char *format, ...)
{ {
va_list va; va_list va;
PyObject *args, *func = 0, *retval; PyObject *args, *func = 0, *retval;
va_start(va, format);
func = lookup_maybe(o, nameid); func = lookup_maybe(o, nameid);
if (func == NULL) { if (func == NULL) {
va_end(va);
if (!PyErr_Occurred()) if (!PyErr_Occurred())
PyErr_SetObject(PyExc_AttributeError, nameid->object); PyErr_SetObject(PyExc_AttributeError, nameid->object);
return NULL; return NULL;
} }
if (format && *format) if (format && *format) {
va_start(va, format);
args = Py_VaBuildValue(format, va); args = Py_VaBuildValue(format, va);
else va_end(va);
}
else {
args = PyTuple_New(0); args = PyTuple_New(0);
}
va_end(va);
if (args == NULL) { if (args == NULL) {
Py_DECREF(func); Py_DECREF(func);
return NULL; return NULL;
@ -1463,23 +1462,22 @@ call_maybe(PyObject *o, _Py_Identifier *nameid, const char *format, ...)
{ {
va_list va; va_list va;
PyObject *args, *func = 0, *retval; PyObject *args, *func = 0, *retval;
va_start(va, format);
func = lookup_maybe(o, nameid); func = lookup_maybe(o, nameid);
if (func == NULL) { if (func == NULL) {
va_end(va);
if (!PyErr_Occurred()) if (!PyErr_Occurred())
Py_RETURN_NOTIMPLEMENTED; Py_RETURN_NOTIMPLEMENTED;
return NULL; return NULL;
} }
if (format && *format) if (format && *format) {
va_start(va, format);
args = Py_VaBuildValue(format, va); args = Py_VaBuildValue(format, va);
else va_end(va);
}
else {
args = PyTuple_New(0); args = PyTuple_New(0);
}
va_end(va);
if (args == NULL) { if (args == NULL) {
Py_DECREF(func); Py_DECREF(func);
return NULL; return NULL;