Handle encoding error in layout file parsing more gracefully

Issue a warning about non-decodable files, but do not break
completely.

Addresses #11736
This commit is contained in:
Juergen Spitzmueller 2020-02-13 08:13:22 +01:00
parent b175f5a315
commit c4da8d38c9

View File

@ -1402,6 +1402,7 @@ def checkLatexConfig(check_config, bool_docbook):
classname = file.split(os.sep)[-1].split('.')[0]
decline = ""
catline = ""
try:
for line in open(file, 'r', encoding='utf8').readlines():
if not empty.match(line) and line[0] != '#'[0]:
if decline == "":
@ -1422,6 +1423,14 @@ def checkLatexConfig(check_config, bool_docbook):
break
if nodeclaration:
continue
except UnicodeDecodeError:
logger.warning("**************************************************\n"
"Layout file '%s'\n"
"cannot be decoded in utf-8.\n"
"Please check if the file has the correct encoding.\n"
"Skipping this file!\n"
"**************************************************" % file)
continue
testclasses.sort()
cl = open('chklayouts.tex', 'w', encoding='utf8')
for line in testclasses: