[Libvir] Python bindings, errors & exceptions
Richard W.M. Jones
rjones at redhat.com
Fri Mar 23 13:28:36 UTC 2007
Daniel P. Berrange wrote:
> Actually looks like it is the generated code actually. The generator.py
> appears to only add in the 'raise libvirtError' stuff if the return value
> is a virConnectPtr/virDomainPtr/virNeworkPtr object - any other function
> with a non-object return value gives back None upon error.
The generator.py code as it stands doesn't deal with the case where a
function is prototyped (in C) as returning 'int'.
If I were to modify generator.py so that it adds the check for functions
returning int, then it doesn't work because there is not enough
information from just the C return type to tell what the Python return
type will be.
As an example:
save
C returns int
Python returns int
Current bindings fail to check for ret < 0 and
raise an exception.
listNetworks
C returns int
Python returns list of networks, or None
Current bindings fail to check for ret == None and
raise an exception.
We could do some run-time type magic in the generated wrapper, although
that seems evil.
I think the above are examples of the only two possible cases.
Rich.
--
Emerging Technologies, Red Hat http://et.redhat.com/~rjones/
64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421
"[Negative numbers] darken the very whole doctrines of the equations
and make dark of the things which are in their nature excessively
obvious and simple" (Francis Maseres FRS, mathematician, 1759)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20070323/cba3f796/attachment-0001.bin>
More information about the libvir-list
mailing list