gdbus-codegen: avoid error when wrong interface is provided to --annotate

If the interface given cannot be matched, `iface_obj' was left uninitialized and
the iface_obj == None check would end up crashing:

Traceback (most recent call last):
  File "/usr/bin/gdbus-codegen", line 41, in <module>
    sys.exit(codegen_main.codegen_main())
  File "/usr/lib64/gdbus-2.0/codegen/codegen_main.py", line 175, in codegen_main
    apply_annotations(all_ifaces, opts.annotate)
  File "/usr/lib64/gdbus-2.0/codegen/codegen_main.py", line 146, in apply_annotations
    apply_annotation(iface_list, iface, None, None, None, None, key, value)
  File "/usr/lib64/gdbus-2.0/codegen/codegen_main.py", line 64, in apply_annotation
    if iface_obj == None:
UnboundLocalError: local variable 'iface_obj' referenced before assignment

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=683088
This commit is contained in:
Aleksander Morgado 2012-08-31 11:41:53 +02:00 committed by Matthias Clasen
parent c270b833a6
commit 724c8a1846

View File

@ -56,6 +56,7 @@ def find_prop(iface, prop):
return None return None
def apply_annotation(iface_list, iface, method, signal, prop, arg, key, value): def apply_annotation(iface_list, iface, method, signal, prop, arg, key, value):
iface_obj = None
for i in iface_list: for i in iface_list:
if i.name == iface: if i.name == iface:
iface_obj = i iface_obj = i