Fixed xml.etree future warning
authorEd Bartosh <eduard.bartosh@intel.com>
Tue, 11 Mar 2014 18:42:50 +0000 (20:42 +0200)
committerZhang Qiang <qiang.z.zhang@intel.com>
Wed, 12 Mar 2014 03:07:22 +0000 (11:07 +0800)
New distros come with new xml.etree API, which produces this warning
when using oscapi:
 /usr/lib/python2.7/site-packages/gitbuildsys/oscapi.py:105:
FutureWarning: The behavior of this method will change in future
versions. Use specific 'len(elem)' or 'elem is not None' test instead.
if element:

This is also mentioned in the python documentation for xml.etree.find API:
Caution: Elements with no subelements will test as False. This behavior
will change in future versions. Use specific len(elem) or elem is None
test instead.

Fixes: #1706
Change-Id: I84c4a947125a8d96584fef609dc5266b97447c0e
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
gitbuildsys/oscapi.py

index dcabc1646f1dc2499d0e080f735ba95d122db996..87554232ff2de0257b6511ce04b2fc8e686ca0f1 100644 (file)
@@ -102,7 +102,7 @@ class OSC(object):
         result = ''
         for tag in tags:
             element = xml_root.find(tag)
-            if element:
+            if element is not None:
                 result += ET.tostring(element)
 
         return result