Commit 3e793e44 authored by Julien Muchembled's avatar Julien Muchembled

fixup! xml_marshaller: stop distinguish unicode and bytes and always return 'str'

We always returned unicode.
parent 357d558c
...@@ -29,6 +29,11 @@ try: ...@@ -29,6 +29,11 @@ try:
cmp cmp
except NameError: except NameError:
cmp = lambda x, y: (x > y) - (x < y) cmp = lambda x, y: (x > y) - (x < y)
def unicode2str(s):
return s
else:
def unicode2str(s):
return s.encode('utf-8')
@cmp_to_key @cmp_to_key
def version_independent_cmp(a, b): def version_independent_cmp(a, b):
...@@ -441,7 +446,7 @@ class Unmarshaller(ElementTreeContentHandler): ...@@ -441,7 +446,7 @@ class Unmarshaller(ElementTreeContentHandler):
def um_end_string(self, name): def um_end_string(self, name):
ds = self.data_stack ds = self.data_stack
ds[-1] = unescape(''.join(ds[-1])) ds[-1] = unicode2str(unescape(''.join(ds[-1])))
self.accumulating_chars = 0 self.accumulating_chars = 0
def um_end_int(self, name): def um_end_int(self, name):
...@@ -583,10 +588,8 @@ class Unmarshaller(ElementTreeContentHandler): ...@@ -583,10 +588,8 @@ class Unmarshaller(ElementTreeContentHandler):
klass.__name__, err)), sys.exc_info()[2]) klass.__name__, err)), sys.exc_info()[2])
# Now set the object's attributes from the marshalled dictionary # Now set the object's attributes from the marshalled dictionary
for k, v in kw.items(): for x in kw.items():
if not isinstance(k, str): setattr(value, *x)
k = k.decode()
setattr(value, k, v)
self.data_stack[-5:] = [value] self.data_stack[-5:] = [value]
# Helper class for instance unmarshalling # Helper class for instance unmarshalling
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment