Re: [libvirt] [libvirt-python][PATCH] generator: fix build fail with old xml lib

2015-09-22 Thread lhuang


On 09/21/2015 06:09 PM, Michal Privoznik wrote:

On 02.09.2015 07:58, Luyao Huang wrote:

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 
---
  generator.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

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):



ACKed and pushed.


Thanks your review, Michal :)


Michal


Luyao

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [libvirt-python][PATCH] generator: fix build fail with old xml lib

2015-09-21 Thread Michal Privoznik
On 02.09.2015 07:58, Luyao Huang wrote:
> 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 
> ---
>  generator.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 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):
> 

ACKed and pushed.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-python][PATCH] generator: fix build fail with old xml lib

2015-09-01 Thread Luyao Huang
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 
---
 generator.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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):
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list