Skip to content

Commit

Permalink
updated errors check for encode/decode
Browse files Browse the repository at this point in the history
  • Loading branch information
ashah-splunk committed Jul 11, 2023
1 parent 9ef371f commit d2a4af2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion splunklib/modularinput/event_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def write_xml_document(self, document):
:param document: An ``ElementTree`` object.
"""
self._out.write(ensure_str(ET.tostring(document)))
self._out.write(ensure_str(ET.tostring(document), errors="replace"))
self._out.flush()

def close(self):
Expand Down
2 changes: 1 addition & 1 deletion splunklib/searchcommands/search_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ def _read_chunk(istream):
except Exception as error:
raise RuntimeError('Failed to read body of length {}: {}'.format(body_length, error))

return metadata, six.ensure_str(body)
return metadata, six.ensure_str(body, errors="replace")

_header = re.compile(r'chunked\s+1.0\s*,\s*(\d+)\s*,\s*(\d+)\s*\n')

Expand Down
2 changes: 1 addition & 1 deletion splunklib/six.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ def ensure_binary(s, encoding='utf-8', errors='strict'):
raise TypeError("not expecting type '%s'" % type(s))


def ensure_str(s, encoding='utf-8', errors='replace'):
def ensure_str(s, encoding='utf-8', errors='strict'):
"""Coerce *s* to `str`.
For Python 2:
Expand Down

0 comments on commit d2a4af2

Please sign in to comment.