From 0c9b209467f2d80390c605a363829134753da544 Mon Sep 17 00:00:00 2001 From: choi se Date: Sun, 26 Jul 2020 16:45:42 +0900 Subject: [PATCH] Fix log-reader for Python3 (#3580) * Fix log-reader for Python3 Signed-off-by: thinker0 * typo Signed-off-by: thinker0 * Revert commit Co-authored-by: thinker0 --- heron/shell/src/python/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/heron/shell/src/python/utils.py b/heron/shell/src/python/utils.py index e5e1cd8f5a1..8223d79a45e 100644 --- a/heron/shell/src/python/utils.py +++ b/heron/shell/src/python/utils.py @@ -135,7 +135,7 @@ 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) @@ -143,7 +143,8 @@ def read_chunk(filename, offset=-1, length=-1, escape_data=False): 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)