From 2d460a98e560cbfc3d87b54a14c9ca13d33cf519 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Sun, 14 Jul 2013 16:01:38 -0400 Subject: [PATCH] xmlbuilder: Don't treat 0 as None in setter impl --- tests/xmlparse-xml/change-disk-out.xml | 4 ++++ virtinst/xmlbuilder.py | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/tests/xmlparse-xml/change-disk-out.xml b/tests/xmlparse-xml/change-disk-out.xml index 82e877b4..7f60efaa 100644 --- a/tests/xmlparse-xml/change-disk-out.xml +++ b/tests/xmlparse-xml/change-disk-out.xml @@ -43,6 +43,10 @@ + 0 + 0 + 0 + 0 5 6 diff --git a/virtinst/xmlbuilder.py b/virtinst/xmlbuilder.py index e5ff398a..4b074b11 100644 --- a/virtinst/xmlbuilder.py +++ b/virtinst/xmlbuilder.py @@ -487,17 +487,18 @@ class XMLProperty(property): if node: use_xpath = node.nodePath() - if val not in [None, False]: - if not node: - node = _build_xpath_node(root_node, use_xpath) - - if val is True: - # Boolean property, creating the node is enough - pass - else: - node.setContent(util.xml_escape(str(val))) - else: + if val is None or val is False: _remove_xpath_node(root_node, use_xpath) + continue + + if not node: + node = _build_xpath_node(root_node, use_xpath) + + if val is True: + # Boolean property, creating the node is enough + continue + node.setContent(util.xml_escape(str(val))) + def refresh_xml(self, xmlbuilder): self.fset(xmlbuilder, self.fget(xmlbuilder), local=False)