diff options
author | Luyao Huang <lhuang@redhat.com> | 2015-09-02 13:58:00 +0800 |
---|---|---|
committer | Michal Privoznik <mprivozn@redhat.com> | 2015-09-21 12:04:59 +0200 |
commit | 3a97b3212d999a6a0c813e256558d1d47b193782 (patch) | |
tree | 5a300ffc055e63f3b51a1cb1a3fdbf3be97e4645 /generator.py | |
parent | 51b841fa5b0214eb56e952b02d82592263775631 (diff) | |
download | libvirt-python-3a97b3212d999a6a0c813e256558d1d47b193782.tar.gz |
generator: fix build fail with old xml lib
https://bugzilla.redhat.com/show_bug.cgi?id=1222795#c6
if build libvirt-python with some old xml lib (python-pyxml),
build will fail and error like this:
File "generator.py", line 139, in start
if "string" in attrs:
File "/usr/local/lib/python2.7/site-packages/_xmlplus/sax/xmlreader.py" \
, line 316, in __getitem__
return self._attrs[name]
KeyError: 0
This is an old issue and have been mentioned in commit 3ae0a76d.
There is no __contains__ in class AttributesImpl, python will use
__getitem__ in this place, so we will get error.
Let's use 'YYY in XXX.keys()' to avoid this issue.
Signed-off-by: Luyao Huang <lhuang@redhat.com>
Diffstat (limited to 'generator.py')
-rwxr-xr-x | generator.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/generator.py b/generator.py index 2fc838c..d9ae17e 100755 --- a/generator.py +++ b/generator.py @@ -136,7 +136,7 @@ class docParser(xml.sax.handler.ContentHandler): elif attrs['file'] == "libvirt-qemu": qemu_enum(attrs['type'],attrs['name'],attrs['value']) elif tag == "macro": - if "string" in attrs: + if "string" in attrs.keys(): params.append((attrs['name'], attrs['string'])) def end(self, tag): |