summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-11-21 13:03:04 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-11-21 13:06:36 -0500
commit0f8d403d1a86cfbfe8222662dc445e16e8f7eff9 (patch)
tree1d88be64858b41fc8a8f7dace060649b6ed9127c
parentf4dc3f33579584924243ac2e89f6f68ed195ec79 (diff)
downloadbcfg2-0f8d403d1a86cfbfe8222662dc445e16e8f7eff9.tar.gz
bcfg2-0f8d403d1a86cfbfe8222662dc445e16e8f7eff9.tar.bz2
bcfg2-0f8d403d1a86cfbfe8222662dc445e16e8f7eff9.zip
Bundler: Fix parsing XML template output with encoding declaration
lxml 3.2.1 complains when you try to parse a unicode (in Python 2) or string (in Python 3) containing an XML document with an encoding declaration. Traceback: ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration. This encodes the document as a string (in Python 2) or bytes (in Python 3) to avoid the lxml error. There may be other places this happens, too, although in most other cases we should use lxml.etree.parse() to parse a file, or we parse strings (in Python 2) instead of unicode objects.
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Bundler.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Bundler.py b/src/lib/Bcfg2/Server/Plugins/Bundler.py
index fb327f7ef..58f8f4430 100644
--- a/src/lib/Bcfg2/Server/Plugins/Bundler.py
+++ b/src/lib/Bcfg2/Server/Plugins/Bundler.py
@@ -53,9 +53,9 @@ if HAS_GENSHI:
stream = self.template.generate(
metadata=metadata,
repo=SETUP['repo']).filter(removecomment)
- data = lxml.etree.XML(stream.render('xml',
- strip_whitespace=False),
- parser=Bcfg2.Server.XMLParser)
+ data = lxml.etree.XML(
+ stream.render('xml', strip_whitespace=False).encode(),
+ parser=Bcfg2.Server.XMLParser)
bundlename = os.path.splitext(os.path.basename(self.name))[0]
bundle = lxml.etree.Element('Bundle', name=bundlename)
for item in self.Match(metadata, data):