Code0x58 commented on a change in pull request #3580:
URL: https://github.com/apache/incubator-heron/pull/3580#discussion_r459163401



##########
File path: heron/shell/src/python/utils.py
##########
@@ -135,21 +135,22 @@ 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)
 
 def _escape_data(data):
-  return escape(data.decode('utf8', 'replace'))

Review comment:
       once the change to this is reverted, the PR will be compatible with the 
python2 behaviour - alternativley you could do the decoding in the `data = ...` 
line above




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to