You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@heron.apache.org by hu...@apache.org on 2020/07/26 07:45:54 UTC
[incubator-heron] branch master updated: Fix log-reader for Python3
(#3580)
This is an automated email from the ASF dual-hosted git repository.
huijun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-heron.git
The following commit(s) were added to refs/heads/master by this push:
new 0c9b209 Fix log-reader for Python3 (#3580)
0c9b209 is described below
commit 0c9b209467f2d80390c605a363829134753da544
Author: choi se <th...@gmail.com>
AuthorDate: Sun Jul 26 16:45:42 2020 +0900
Fix log-reader for Python3 (#3580)
* Fix log-reader for Python3
Signed-off-by: thinker0 <th...@linecorp.com>
* typo
Signed-off-by: thinker0 <th...@linecorp.com>
* Revert commit
Co-authored-by: thinker0 <th...@linecorp.com>
---
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 e5e1cd8..8223d79 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)