fix reading directly from file handle
This commit is contained in:
1 parent
d6d981a351
commit
f17e461fdd
1 file changed
+1
-1
@@ -29,7 +29,7 @@ def popcount(a):
|
|||||||
def readtext(file):
|
def readtext(file):
|
||||||
"""Reads and returns the text in a given file. Transparently decompresses \\*.gz files."""
|
"""Reads and returns the text in a given file. Transparently decompresses \\*.gz files."""
|
||||||
if hasattr(file, 'read'):
|
if hasattr(file, 'read'):
|
||||||
return file.read()
|
return file.read().decode()
|
||||||
if str(file).endswith('.gz'):
|
if str(file).endswith('.gz'):
|
||||||
with gzip.open(file, 'rt') as f:
|
with gzip.open(file, 'rt') as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
|
|||||||
Reference in new issue
Block a user