[LyX/2.3.x] Consider file encoding for modules in reconfigure

José Matos jamatos at lyx.org
Sat Aug 15 19:37:17 UTC 2020


commit f5489036305eae3e63e721e2714746bd48bac1dc
Author: José Matos <jamatos at lyx.org>
Date:   Sat Aug 15 21:02:38 2020 +0100

    Consider file encoding for modules in reconfigure
    
    If the modules are not in utf8 then we warn and skip that file
    like it happens for layout files.
    
    This a port of commit a8094051c1ae9c546c76bb0d3300d83e6cdbadef to stable.
---
 lib/configure.py |   18 +++++++++++++-----
 status.23x       |    6 +++++-
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/lib/configure.py b/lib/configure.py
index a5a49b7..7fee68d 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -228,7 +228,7 @@ def checkTeXPaths():
             if sys.version_info[0] < 3:
                 inpname = shortPath(unicode(tmpfname, encoding)).replace('\\', '/')
             else:
-                inpname = shortPath(tmpfname).replace('\\', '/') 
+                inpname = shortPath(tmpfname).replace('\\', '/')
         else:
             inpname = cmdOutput('cygpath -m ' + tmpfname)
         logname = os.path.basename(re.sub("(?i).ltx", ".log", inpname))
@@ -1174,7 +1174,7 @@ def checkConverterEntries():
 \converter svgz       png        "%%"    ""'''],
             path = ['', inkscape_path])
     #
-    checkProg('Gnuplot', ['gnuplot'], 
+    checkProg('Gnuplot', ['gnuplot'],
         rc_entry = [ r'''\Format gnuplot     "gp, gnuplot"    "Gnuplot"     "" "" ""  "vector"	"text/plain"
 \converter gnuplot      pdf6      "python -tt $$s/scripts/gnuplot2pdf.py $$i $$o"    "needauth"''' ])
     #
@@ -1584,9 +1584,17 @@ def checkModulesConfig():
           continue
 
       seen.append(filename)
-      retval = processModuleFile(file, filename, bool_docbook)
-      if retval:
-          tx.write(retval)
+      try:
+          retval = processModuleFile(file, filename, bool_docbook)
+          if retval:
+              tx.write(retval)
+      except UnicodeDecodeError:
+          logger.warning("**************************************************\n"
+                         "Module file '%s'\n"
+                         "cannot be decoded in utf-8.\n"
+                         "Please check if the file has the correct encoding.\n"
+                         "Skipping this file!\n"
+                         "**************************************************" % filename)
   tx.close()
   logger.info('\tdone')
 
diff --git a/status.23x b/status.23x
index f8420a1..0a75945 100644
--- a/status.23x
+++ b/status.23x
@@ -88,7 +88,7 @@ What's new
 
 - Do not allow editing of math package list in Document > Settings > Math Options,
   thus preventing a crash (bug 11931).
-  
+
 - Maintain standard layout for separating paragraphs when switching layouts (bug 11936).
 
 
@@ -114,3 +114,7 @@ What's new
 
 - Wininstaller, fix bug where previous installations, with emergency version
   greater than 1, could not be seen in registry on overinstall
+
+- Do not break configuration if a module file is not decodable (file
+  not encoded in utf-8). Rather than that, issue a warning and skip
+  that file (a variant of bug 11736).


More information about the lyx-cvs mailing list