Skip to content

Commit 05f789c

Browse files
authored
Merge pull request splunk#206 from splunk/bug/DVPL-7312-exceptions-raised-for-unicode-characters
Fix XML responses to not throw errors for unicode characters in `splunklib/data.py` `load` function.
2 parents f96b8ad + e10e50d commit 05f789c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

splunklib/data.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"""
1818

1919
from __future__ import absolute_import
20+
import sys
2021
from xml.etree.ElementTree import XML
2122
from splunklib import six
2223

@@ -76,6 +77,11 @@ def load(text, match=None):
7677
'namespaces': [],
7778
'names': {}
7879
}
80+
81+
# Convert to unicode encoding in only python 2 for xml parser
82+
if(sys.version_info < (3, 0, 0) and isinstance(text, unicode)):
83+
text = text.encode('utf-8')
84+
7985
root = XML(text)
8086
items = [root] if match is None else root.findall(match)
8187
count = len(items)

0 commit comments

Comments
 (0)