[libvirt] [PATCH python] Fix code for avoiding overrides of non-existant functions

From: "Daniel P. Berrange" <berrange@redhat.com> When reading/writing a global variable from inside a method it must be declared as a global, otherwise a local variable by the same name will be used. Special case the virConnectListDomainsID method which is bizarrely renamed for no obvious reason. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- generator.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/generator.py b/generator.py index cd857b4..e8d8ea9 100755 --- a/generator.py +++ b/generator.py @@ -187,16 +187,21 @@ class docParser(xml.sax.handler.ContentHandler): def function(name, desc, ret, args, file, module, cond): + global onlyOverrides if onlyOverrides and name not in functions: return + if name == "virConnectListDomains": + name = "virConnectListDomainsID" functions[name] = (desc, ret, args, file, module, cond) def qemu_function(name, desc, ret, args, file, module, cond): + global onlyOverrides if onlyOverrides and name not in qemu_functions: return qemu_functions[name] = (desc, ret, args, file, module, cond) def lxc_function(name, desc, ret, args, file, module, cond): + global onlyOverrides if onlyOverrides and name not in lxc_functions: return lxc_functions[name] = (desc, ret, args, file, module, cond) @@ -786,6 +791,7 @@ def buildStubs(module, api_xml): global py_types global py_return_types global unknown_types + global onlyOverrides if module not in ["libvirt", "libvirt-qemu", "libvirt-lxc"]: print "ERROR: Unknown module type: %s" % module -- 1.8.3.1

On 11/27/2013 04:14 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
When reading/writing a global variable from inside a method it must be declared as a global, otherwise a local variable by the same name will be used.
Special case the virConnectListDomainsID method which is bizarrely renamed for no obvious reason.
It's such an old binding (predates my time on libvirt), but I suspect it may have been done with the foresight that returning a list of integer ids is not as useful as a list of python objects; if nothing else, it means that connect.ListDomains is still available as a shorter name than connect.ListDomainsAll for our newer APIs that return objects to begin with.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- generator.py | 6 ++++++ 1 file changed, 6 insertions(+)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Daniel P. Berrange
-
Eric Blake