[libvirt] [PATCH] python: prefer PyList_SET_ITEM to PyList_SetItem

Martin Kletzander mkletzan at redhat.com
Wed Nov 6 07:00:11 UTC 2013


On Tue, Nov 05, 2013 at 05:00:53PM +0100, Giuseppe Scrivano wrote:
> Martin Kletzander <mkletzan at redhat.com> writes:
> 
> > Not that it has any connection to your patch, but I noticed that,
> > somewhere, we check the return value of PyList_New(), but somewhere we
> > don't...  I guess we should do it everywhere, shouldn't we?
> >
> > ... thinking about it, I searched through the code and
> > PyList_SetItem() properly errors out when 'op' (its first param) is
> > NULL, but PyList_SET_ITEM() will just segfault.  I think we should
> > properly handle allocation errors before optimizing it this way.
> 
> Great you have noticed it.  I expected PyList_SetItem to crash too when
> the list == NULL.
> 

Oh, you're right.  I was blinded by the fact, that PyList_SetItem()
checks whether the 'op' is a list and I was under the impression that
PyList_Check(op) will catch that.  This has not yet changed (I checked
3.3.2), so you're right, the fact that we'll use PyList_SET_ITEM won't
change a thing.  I'll continue with the review in a minute.  Thanks
for the idea.

Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20131106/6f40267e/attachment-0001.sig>


More information about the libvir-list mailing list