Skip to content

Commit 6f63ec1

Browse files
committed
add workaround for python 2.7
1 parent 4f4e609 commit 6f63ec1

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tests/searchcommands/chunked_data_stream.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,22 @@ def _build_data_csv(data):
8282
return b''
8383
if isinstance(data, bytes):
8484
return data
85-
csvout = io.StringIO()
85+
if six.PY2:
86+
csvout = io.BytesIO()
87+
else:
88+
csvout = io.StringIO()
89+
8690
headers = set()
8791
for datum in data:
88-
headers.update(datum.keys())
92+
if six.PY2:
93+
headers.update(datum.keys())
94+
else:
95+
headers.update(datum.keys())
8996
writer = csv.DictWriter(csvout, headers, dialect=splunklib.searchcommands.internals.CsvDialect)
9097
writer.writeheader()
9198
for datum in data:
92-
writer.writerow(datum)
93-
return csvout.getvalue().encode("utf-8")
99+
if six.PY2:
100+
writer.writerow(datum)
101+
else:
102+
writer.writerow(datum)
103+
return six.ensure_binary(csvout.getvalue())

0 commit comments

Comments
 (0)