diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Bcfg2/Client/XML.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lib/Bcfg2/Client/XML.py b/src/lib/Bcfg2/Client/XML.py index 1f1b7df7d..561cd25a8 100644 --- a/src/lib/Bcfg2/Client/XML.py +++ b/src/lib/Bcfg2/Client/XML.py @@ -8,14 +8,17 @@ try: from lxml.etree import Element, SubElement, tostring from lxml.etree import XMLSyntaxError as ParseError from lxml.etree import XML as _XML + from Bcfg2.Compat import wraps driver = 'lxml' + @wraps(_XML) def XML(val, **kwargs): + """ unicode strings w/encoding declaration are not supported in + recent lxml.etree, so we try to read XML, and if it fails we try + encoding the string. """ try: return _XML(val, **kwargs) except ValueError: - # unicode strings w/encoding declaration are not supported - # in recent lxml.etree return _XML(val.encode(), **kwargs) except ImportError: # lxml not available |