Skip to content

Commit

Permalink
wmllint: fixed an error when trying to check if a file is a savegame
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Elvish-Hunter committed Aug 25, 2015
1 parent a55bc98 commit def7248
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions data/tools/wesnoth/wmltools.py
Expand Up @@ -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):
Expand Down

0 comments on commit def7248

Please sign in to comment.