[Libvir] [PATCH] Add Python binding for virGetVersion

Mark McLoughlin markmc at redhat.com
Tue May 29 12:49:26 UTC 2007

On Tue, 2007-05-29 at 12:43 +0100, Richard W.M. Jones wrote:

>  >>> libvirt.getVersion ("Xen");
> (2002, 3000001)
>  >>> libvirt.getVersion (None);
> 2002

	I don't think it's a big deal, but I was suggesting these two should be
equivalent - i.e. None == "Xen". That's why the code I posted explicitly
checked for a zero length arg list - if you used "|z" with
PyArg_ParseTuple(), you wouldn't be able[1] to distinguish between no
args and None.

	Either that, or just don't allow None as an argument at all - i.e. pass
"|s" to PyArg_ParseTuple().


[1] - barring doing something ugly like:

  char *type = (char *) -1;

  parse(args, "|z", &type);

  if (type == (char *) -1)
      return libVer;
  else if (type == NULL)
      return getVer("xen");
      return getVer(type);

More information about the libvir-list mailing list