python3 compat: python3 strings have no decode()

This commit is contained in:
Radostin Stoyanov 2017-10-11 12:35:58 +01:00 committed by Cole Robinson
parent 4d9c6141dd
commit 5146d66126
1 changed files with 5 additions and 1 deletions

View File

@ -829,7 +829,11 @@ class XMLBuilder(object):
self.conn = conn
if self._XML_SANITIZE:
parsexml = parsexml.decode('ascii', 'ignore').encode('ascii')
if hasattr(parsexml, 'decode'):
parsexml = parsexml.decode("ascii", "ignore").encode("ascii")
else:
parsexml = parsexml.encode("ascii", "ignore").decode("ascii")
parsexml = "".join([c for c in parsexml if c in string.printable])
self._propstore = {}