On 11/21/19 10:58 AM, Richard W.M. Jones wrote:
It is unclear why we were constructing this by hand, but using the following tip we can use PyObject_CallFunction: https://stackoverflow.com/a/21221335 --- plugins/python/python.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
- r = PyObject_CallObject (fn, args); + r = PyObject_CallFunction (fn, "OiLO", + obj, count, offset, + may_trim ? Py_True : Py_False, NULL);
The use of trailing ', NULL' is appears to be copy-and-paste from my earlier commit 5ae45c00, where I used it on 3 of the 4 conversions made there. It is not necessary, nor is it mentioned in the mentioned stackoverflow link. If you have a format string, a trailing NULL is not necessary because the format string tells how many varargs to consume; but with PyObject_CallFunctionObjArgs, a trailing NULL is necessary because there is no format string and the varargs are parsed as a series of Python objects until a trailing NULL terminator is encountered. I've pushed an obvious cleanup patch. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org