wmllint: Leave gzipped binary files alone, they're not safe for consumption
Fixes wmllint crashing like this upon encountering a gzip tarball in an add-on: Traceback (most recent call last): File "/home/shadowm/bin/wmllint-1.14", line 3188, in <module> for fn in allcfgfiles(directory): File "/home/shadowm/bin/wmllint-1.14", line 2944, in allcfgfiles if interesting(os.path.join(root, name)): File "/home/shadowm/bin/wmllint-1.14", line 2927, in interesting return fn.endswith(".cfg") or is_map(fn) or issave(fn) File "/home/shadowm/src/wesnoth-1.14/data/tools/wesnoth/wmltools3.py", line 270, in issave return firstline.startswith("label=") TypeError: startswith first arg must be bytes or a tuple of bytes, not str [ci skip]
This commit is contained in:
parent
ff82a007d5
commit
c92e167a14
2 changed files with 4 additions and 0 deletions
|
@ -84,6 +84,7 @@
|
|||
selection dialog is dismissed.
|
||||
* Fixed an issue with positioned sound sources ignoring the volume set in
|
||||
Preferences after going off the audible radius and back (issue #3280).
|
||||
* Fixed wmllint choking on gzipped binary files (e.g. gzipped tarballs).
|
||||
|
||||
## Version 1.14.3
|
||||
### AI
|
||||
|
|
|
@ -260,6 +260,9 @@ def issave(filename):
|
|||
if filename.endswith(".gz"):
|
||||
with gzip.open(filename) as content:
|
||||
firstline = content.readline()
|
||||
if not isinstance(firstline, str):
|
||||
# It's a compressed binary file
|
||||
return False
|
||||
else:
|
||||
try:
|
||||
with codecs.open(filename, "r", "utf8") as content:
|
||||
|
|
Loading…
Add table
Reference in a new issue