-
Notifications
You must be signed in to change notification settings - Fork 380
Fix XML responses to not throw errors for unicode characters #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix XML responses to not throw errors for unicode characters #206
Conversation
Changed `splunklib/data.py` `load` function to convert text provided into a utf-8 string so that Python XML parser will not throw errors when processing utf-8 encoded responses.
…ncoded only for utf strings, so that Python XML parser will not throw errors when processing utf-8 encoded responses.
splunklib/data.py
Outdated
@@ -76,6 +77,12 @@ def load(text, match=None): | |||
'namespaces': [], | |||
'names': {} | |||
} | |||
|
|||
# Convert to unicode encoding in only python 2 for xml parser | |||
if sys.version_info < (3, 0, 0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can use and
and combine these into a single if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one small change
splunklib/data.py
Outdated
if sys.version_info < (3, 0, 0): | ||
if isinstance(text, unicode): | ||
text = text.encode('utf-8') | ||
if(sys.version_info < (3, 0, 0) and isinstance(text, unicode)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: outer parens aren't necessary but LGTM
Changed
splunklib/data.py
load
function to convert text provided into a utf-8 string so that Python XML parser will not throw errors when processing utf-8 encoded responses.