From 50e21b71663bab7ed48e830a5d641553ef190586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20St=C3=B6hr?= Date: Tue, 4 Apr 2017 22:35:49 +0200 Subject: [PATCH] configure.py: add support for Python 3 on Windows fixes the last missing part of bug #9006 (hopefully) --- lib/configure.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/configure.py b/lib/configure.py index aae6a85990..be47cea7a0 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -9,7 +9,7 @@ # Full author contact details are available in file CREDITS. from __future__ import print_function -import glob, logging, os, re, shutil, subprocess, sys, stat +import glob, logging, os, re, shutil, subprocess, sys, stat, io # set up logging logging.basicConfig(level = logging.DEBUG, @@ -200,12 +200,12 @@ def checkTeXPaths(): if sys.version_info[0] < 3: inpname = shortPath(unicode(tmpfname, encoding)).replace('\\', '/') else: - inpname = shortPath(str(tmpfname, encoding)).replace('\\', '/') + inpname = shortPath(tmpfname).replace('\\', '/') else: inpname = cmdOutput('cygpath -m ' + tmpfname) logname = os.path.basename(re.sub("(?i).ltx", ".log", inpname)) inpname = inpname.replace('~', '\\string~') - os.write(fd, r'\relax') + os.write(fd, b'\\relax') os.close(fd) latex_out = cmdOutput(r'latex "\nonstopmode\input{%s}\makeatletter\@@end"' % inpname) @@ -1349,7 +1349,11 @@ def checkLatexConfig(check_config, bool_docbook): classname = file.split(os.sep)[-1].split('.')[0] decline = "" catline = "" - for line in open(file).readlines(): + if os.name == 'nt': + enco = sys.getfilesystemencoding() + else: + enco="utf8" + for line in io.open(file, encoding=enco).readlines(): if not empty.match(line) and line[0] != '#': if decline == "": logger.warning("Failed to find valid \Declare line "