Skip to content
Permalink
Browse files
Fix log-reader for Python3 (#3580)
* Fix log-reader for Python3

Signed-off-by: thinker0 <thinker0@linecorp.com>

* typo

Signed-off-by: thinker0 <thinker0@linecorp.com>

* Revert commit

Co-authored-by: thinker0 <thinker0@linecorp.com>
  • Loading branch information
thinker0 and thinker0 committed Jul 26, 2020
1 parent d9c06bd commit 0c9b209467f2d80390c605a363829134753da544
Showing 1 changed file with 3 additions and 2 deletions.
@@ -135,15 +135,16 @@ def read_chunk(filename, offset=-1, length=-1, escape_data=False):
if length == -1:
length = fstat.st_size - offset

with open(filename, "r") as fp:
with open(filename, "rb") as fp:
fp.seek(offset)
try:
data = fp.read(length)
except IOError:
return {}

if data:
data = _escape_data(data) if escape_data else data
# use permissive decoding and escaping if escape_data is set, otherwise use strict decoding
data = _escape_data(data) if escape_data else data.decode()
return dict(offset=offset, length=len(data), data=data)

return dict(offset=offset, length=0)

0 comments on commit 0c9b209

Please sign in to comment.