[Libvir] python/libvir.c returning wrong value on error?

Daniel P. Berrange berrange at redhat.com
Wed Feb 6 20:24:17 UTC 2008


On Wed, Feb 06, 2008 at 03:18:13PM -0500, Cole Robinson wrote:
> Hi all,
> 
> Looking at python/libvir.c, all the custom functions return VIR_PY_NONE
> on error. This unfortunately doesn't map well to some of the
> generated python bindings which expect an error val of -1. So if these
> commands fail, no exception will be thrown at the python level.
> (Ex. virDomainGetAutostart, virDomainGetVcpus and their python equiv.)
> 
> I'm wondering where the fix should be: in python/libvir.c, changing
> these error return values, or in the generator somewhere?

The fix should be in the libvir.c file - I didn't write this custom
bindings correctly. Simply remove the line

    if (c_retval < 0)
        return VIR_PY_NONE;

So 'c_retval' will get propagated back to the pure python layer which
will do the -1 check

Regards,
Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 




More information about the libvir-list mailing list