On Sat, Sep 26, 2015 at 09:24:30AM -0400, John Ferlan wrote:
in the subject "instead of Py_None"
and perhaps a few more details in the commit message regarding what's
being done and why
Thanks, I'll update the commit message.
On 09/24/2015 10:01 AM, Pavel Hrdina wrote:
> Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
> ---
> libvirt-override.c | 9 +++------
> typewrappers.c | 54 ++++++++++++++++++------------------------------------
> 2 files changed, 21 insertions(+), 42 deletions(-)
>
> diff --git a/libvirt-override.c b/libvirt-override.c
> index d2279de..4d0fb92 100644
> --- a/libvirt-override.c
> +++ b/libvirt-override.c
> @@ -1960,7 +1960,6 @@ virConnectCredCallbackWrapper(virConnectCredentialPtr cred,
> for (i = 0; i < ncred; i++) {
> PyObject *pycreditem;
> pycreditem = PyList_New(5);
> - Py_INCREF(Py_None);
I'm curious as to why it was done before and why it's OK to remove it.
The others mostly make sense - this functions usage is, well, odd
This first increment of Py_None is used there [1] ...
John
> PyTuple_SetItem(pycred, i, pycreditem);
> PyList_SetItem(pycreditem, 0, libvirt_intWrap((long) cred[i].type));
> PyList_SetItem(pycreditem, 1, libvirt_constcharPtrWrap(cred[i].prompt));
> @@ -1968,17 +1967,15 @@ virConnectCredCallbackWrapper(virConnectCredentialPtr cred,
> PyList_SetItem(pycreditem, 2,
> libvirt_constcharPtrWrap(cred[i].challenge));
> } else {
> - Py_INCREF(Py_None);
> - PyList_SetItem(pycreditem, 2, Py_None);
> + PyList_SetItem(pycreditem, 2, VIR_PY_NONE);
> }
> if (cred[i].defresult) {
> PyList_SetItem(pycreditem, 3,
> libvirt_constcharPtrWrap(cred[i].defresult));
> } else {
> - Py_INCREF(Py_None);
> - PyList_SetItem(pycreditem, 3, Py_None);
> + PyList_SetItem(pycreditem, 3, VIR_PY_NONE);
> }
> - PyList_SetItem(pycreditem, 4, Py_None);
> + PyList_SetItem(pycreditem, 4, VIR_PY_NONE);
[1], the other increments are directly before using the Py_None object.
Pavel
> }
>
> PyTuple_SetItem(list, 0, pycred);
[...]