Handle unicode decode error as not text file - #77

This commit is contained in:
Daniele Rondina
2019-08-17 17:16:51 +02:00
parent 0b24448404
commit 8647a8739d
+1 -1
View File
@@ -1927,7 +1927,7 @@ def istextfile(filename, blocksize = 512):
try:
with open(filename, "r") as f:
r = istext(f.read(blocksize))
except (OSError, IOError):
except (OSError, IOError, UnicodeDecodeError):
return False
return r