浏览代码

HUE-1851 - Detection of compressed binary file types in Python 3 runtime needs to treat data as bytes

Rick Bernotas 4 年之前
父节点
当前提交
d9993df5fa
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      apps/filebrowser/src/filebrowser/views.py

+ 3 - 3
apps/filebrowser/src/filebrowser/views.py

@@ -936,18 +936,18 @@ def _read_simple(fhandle, path, offset, length, stats):
 
 def detect_gzip(contents):
   '''This is a silly small function which checks to see if the file is Gzip'''
-  return contents[:2] == '\x1f\x8b'
+  return contents[:2] == b'\x1f\x8b'
 
 
 def detect_bz2(contents):
   '''This is a silly small function which checks to see if the file is Bz2'''
-  return contents[:3] == 'BZh'
+  return contents[:3] == b'BZh'
 
 
 def detect_avro(contents):
   '''This is a silly small function which checks to see if the file is Avro'''
   # Check if the first three bytes are 'O', 'b' and 'j'
-  return contents[:3] == '\x4F\x62\x6A'
+  return contents[:3] == b'\x4F\x62\x6A'
 
 
 def detect_snappy(contents):