Skip to content

Commit 9613e43

Browse files
committed
Fix XML responses to not throw errors for unicode characters
1 parent 8874404 commit 9613e43

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

splunklib/data.py

Lines changed: 5 additions & 2 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

@@ -77,8 +78,10 @@ def load(text, match=None):
7778
'names': {}
7879
}
7980

80-
if isinstance(text, unicode):
81-
text = text.encode('utf-8')
81+
# Convert to unicode encoding in only python 2 for xml parser
82+
if sys.version_info < (3, 0, 0):
83+
if isinstance(text, unicode):
84+
text = text.encode('utf-8')
8285

8386
root = XML(text)
8487
items = [root] if match is None else root.findall(match)

0 commit comments

Comments
 (0)