summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2023-04-09 10:59:05 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-04-09 10:59:13 (GMT)
commit79cf78dcf438803b4402b922188f6cbcb863d274 (patch)
tree7c8bb2c4ab913b44864bf1f40e1431685b2dd30f
parentffd0759c7a27e963d74d2e6155907d18a897a514 (diff)
parentb855674f5de6adb4f4b34a87955ace957fa9bf90 (diff)
downloadCMake-79cf78dcf438803b4402b922188f6cbcb863d274.zip
CMake-79cf78dcf438803b4402b922188f6cbcb863d274.tar.gz
CMake-79cf78dcf438803b4402b922188f6cbcb863d274.tar.bz2
Merge topic 'python-file-encoding'
b855674f5d Tests: Always load presets schema as UTF-8 0de00b8b69 Sphinx: Modernize UTF-8 encoding handling when updating CMake.qhp f0d6010cb5 Sphinx: Specify encoding when opening files for title extraction Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !8402
-rw-r--r--Tests/RunCMake/CMakePresets/validate_schema.py6
-rw-r--r--Utilities/Sphinx/cmake.py5
-rwxr-xr-xUtilities/Sphinx/create_identifiers.py8
3 files changed, 10 insertions, 9 deletions
diff --git a/Tests/RunCMake/CMakePresets/validate_schema.py b/Tests/RunCMake/CMakePresets/validate_schema.py
index b2a67fc..836147a 100644
--- a/Tests/RunCMake/CMakePresets/validate_schema.py
+++ b/Tests/RunCMake/CMakePresets/validate_schema.py
@@ -4,13 +4,13 @@ import os.path
import sys
-with open(sys.argv[1], "rb") as f:
- contents = json.loads(f.read().decode("utf-8-sig"))
+with open(sys.argv[1], "r", encoding="utf-8-sig") as f:
+ contents = json.load(f)
schema_file = os.path.join(
os.path.dirname(__file__),
"..", "..", "..", "Help", "manual", "presets", "schema.json")
-with open(schema_file) as f:
+with open(schema_file, "r", encoding="utf-8") as f:
schema = json.load(f)
jsonschema.validate(contents, schema)
diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py
index 2ccaf9a..ffef5b3 100644
--- a/Utilities/Sphinx/cmake.py
+++ b/Utilities/Sphinx/cmake.py
@@ -242,12 +242,13 @@ class CMakeTransform(Transform):
The cmake --help-*-list commands also depend on this convention.
Return the title or False if the document file does not exist.
"""
- env = self.document.settings.env
+ settings = self.document.settings
+ env = settings.env
title = self.titles.get(docname)
if title is None:
fname = os.path.join(env.srcdir, docname+'.rst')
try:
- f = open(fname, 'r')
+ f = open(fname, 'r', encoding=settings.input_encoding)
except IOError:
title = False
else:
diff --git a/Utilities/Sphinx/create_identifiers.py b/Utilities/Sphinx/create_identifiers.py
index 0ff39a0..61dd819 100755
--- a/Utilities/Sphinx/create_identifiers.py
+++ b/Utilities/Sphinx/create_identifiers.py
@@ -6,12 +6,12 @@ if len(sys.argv) != 2:
sys.exit(-1)
name = sys.argv[1] + "/CMake.qhp"
-f = open(name, "rb")
+f = open(name, "r", encoding="utf-8")
if not f:
sys.exit(-1)
-lines = f.read().decode("utf-8").splitlines()
+lines = f.read().splitlines()
if not lines:
sys.exit(-1)
@@ -47,5 +47,5 @@ for line in lines:
line = part1 + prefix + "id=\"" + domain_object_type + "/" + domain_object + "\" " + part2
newlines.append(line + "\n")
-f = open(name, "wb")
-f.writelines(map(lambda line: line.encode("utf-8"), newlines))
+f = open(name, "w", encoding="utf-8")
+f.writelines(newlines)