From da21b279e2fa7d5c94ec370c02a7507f91d8ce43 Mon Sep 17 00:00:00 2001 From: Clint Byrum Date: Wed, 20 May 2015 23:42:53 -0700 Subject: Fix xml issues with python3 Some calls in etree will return bytes where they used to return a string type. --- src/saml2/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/saml2/__init__.py') diff --git a/src/saml2/__init__.py b/src/saml2/__init__.py index 87bfafa6..5d3c3514 100644 --- a/src/saml2/__init__.py +++ b/src/saml2/__init__.py @@ -674,7 +674,11 @@ class SamlBase(ExtensionContainer): return ElementTree.tostring(self._to_element_tree(), encoding="UTF-8") def __str__(self): - return self.to_string() + # Yes this is confusing. http://bugs.python.org/issue10942 + x = self.to_string() + if not isinstance(x, six.string_types): + x = x.decode('utf-8') + return x def keyswv(self): """ Return the keys of attributes or children that has values -- cgit v1.2.1