Skip to content

Commit d2a4af2

Browse files
committed
updated errors check for encode/decode
1 parent 9ef371f commit d2a4af2

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

splunklib/modularinput/event_writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def write_xml_document(self, document):
7777
7878
:param document: An ``ElementTree`` object.
7979
"""
80-
self._out.write(ensure_str(ET.tostring(document)))
80+
self._out.write(ensure_str(ET.tostring(document), errors="replace"))
8181
self._out.flush()
8282

8383
def close(self):

splunklib/searchcommands/search_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ def _read_chunk(istream):
934934
except Exception as error:
935935
raise RuntimeError('Failed to read body of length {}: {}'.format(body_length, error))
936936

937-
return metadata, six.ensure_str(body)
937+
return metadata, six.ensure_str(body, errors="replace")
938938

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

splunklib/six.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ def ensure_binary(s, encoding='utf-8', errors='strict'):
898898
raise TypeError("not expecting type '%s'" % type(s))
899899

900900

901-
def ensure_str(s, encoding='utf-8', errors='replace'):
901+
def ensure_str(s, encoding='utf-8', errors='strict'):
902902
"""Coerce *s* to `str`.
903903
904904
For Python 2:

0 commit comments

Comments
 (0)