summaryrefslogtreecommitdiffstats
path: root/Utilities
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2023-04-07 08:11:05 (GMT)
committerCraig Scott <craig.scott@crascit.com>2023-04-07 08:11:05 (GMT)
commitf0d6010cb58b9ca707e696b2e97594481fc3c545 (patch)
tree6b6506594cc7dd453569cf75e2d0164107a32926 /Utilities
parent0dcb5456029e98c41153bcf4377cd406781c4df4 (diff)
downloadCMake-f0d6010cb58b9ca707e696b2e97594481fc3c545.zip
CMake-f0d6010cb58b9ca707e696b2e97594481fc3c545.tar.gz
CMake-f0d6010cb58b9ca707e696b2e97594481fc3c545.tar.bz2
Sphinx: Specify encoding when opening files for title extraction
When the encoding is not specified, open() may choose an encoding based on the locale in use. That encoding may have no relationship to the encoding of the file being opened. Use the locale from the document settings instead, which should better match the file's encoding. Fixes: #24679
Diffstat (limited to 'Utilities')
-rw-r--r--Utilities/Sphinx/cmake.py5
1 files changed, 3 insertions, 2 deletions
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: