wmllint: fixed an error when trying to check if a file is a savegame
The error was caused by the fact that opening a file with codecs.open() is much stricter than using open(mode=rb), and throws a UnicodeDecodeError if a file can't be read as UTF-8 - which is the case for binary files.
This commit is contained in:
parent
a55bc98630
commit
def724816f
1 changed files with 6 additions and 2 deletions
|
@ -199,8 +199,12 @@ def issave(filename):
|
|||
with gzip.open(filename) as content:
|
||||
firstline = content.readline()
|
||||
else:
|
||||
with codecs.open(filename, "r", "utf8") as content:
|
||||
firstline = content.readline()
|
||||
try:
|
||||
with codecs.open(filename, "r", "utf8") as content:
|
||||
firstline = content.readline()
|
||||
except UnicodeDecodeError:
|
||||
# our saves are in UTF-8, so this file shouldn't be one
|
||||
return False
|
||||
return firstline.startswith("label=")
|
||||
|
||||
def isresource(filename):
|
||||
|
|
Loading…
Add table
Reference in a new issue