Closed dtrudg closed 8 years ago
Thanks for reporting. This is most likely a bug....
Could you please check for me if it works correctly if you use the following:
e.text = unicode(v)
Erwin
Confirm that change fixes the issue - it accepts unicode strings now, and they go into OTRS as expected.
diff --git a/otrs/objects.py b/otrs/objects.py
index b75bef4..fd7fb8f 100644
--- a/otrs/objects.py
+++ b/otrs/objects.py
@@ -100,7 +100,7 @@ class OTRSObject(object):
e = etree.Element(k)
if isinstance(e, str): # True
v = v.encode('utf-8')
- e.text = str(v)
+ e.text = unicode(v)
root.append(e)
return root
When using python-otrs to submit an article where the text contains unicode (\u210c in this case), the following error occurs:
Apologies for screenshot instead of text
Looking in objects.py around line 103, I don't really understand what's going on here.
The
# True
comment here suggests that v is always being encoded as utf-8, but then str(v) is applied where an encoding error is being raised.Not sure whether this is a bug, or there is a certain way in which python-otrs is should be passed unicode content?
Thanks,