Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Commit 0c9b209

Browse files
authored
Fix log-reader for Python3 (#3580)
* Fix log-reader for Python3 Signed-off-by: thinker0 <[email protected]> * typo Signed-off-by: thinker0 <[email protected]> * Revert commit Co-authored-by: thinker0 <[email protected]>
1 parent d9c06bd commit 0c9b209

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

heron/shell/src/python/utils.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,16 @@ def read_chunk(filename, offset=-1, length=-1, escape_data=False):
135135
if length == -1:
136136
length = fstat.st_size - offset
137137

138-
with open(filename, "r") as fp:
138+
with open(filename, "rb") as fp:
139139
fp.seek(offset)
140140
try:
141141
data = fp.read(length)
142142
except IOError:
143143
return {}
144144

145145
if data:
146-
data = _escape_data(data) if escape_data else data
146+
# use permissive decoding and escaping if escape_data is set, otherwise use strict decoding
147+
data = _escape_data(data) if escape_data else data.decode()
147148
return dict(offset=offset, length=len(data), data=data)
148149

149150
return dict(offset=offset, length=0)

0 commit comments

Comments
 (0)