summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjellahlstedt@gmail.com>2021-07-17 12:19:58 +0200
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2021-07-17 12:19:58 +0200
commit43e37bd7591c7df340191c1f9c8aafd17751aa0b (patch)
tree9fae991f57a2c8e0f8959412c3833ce643f53b16
parentd2006f9cc7df4746356ec6802a1c71d719015f26 (diff)
downloadmm-common-43e37bd7591c7df340191c1f9c8aafd17751aa0b.tar.gz
Python scripts: Specify file encoding
The default file encoding is platform dependent in Python. Better tell which encoding to use when text files are written.
-rwxr-xr-xutil/build_scripts/dist-changelog.py3
-rwxr-xr-xutil/build_scripts/generate-binding.py2
-rwxr-xr-xutil/meson_aux/extra-dist-cmd.py3
3 files changed, 5 insertions, 3 deletions
diff --git a/util/build_scripts/dist-changelog.py b/util/build_scripts/dist-changelog.py
index 5eecb1a..b3677bf 100755
--- a/util/build_scripts/dist-changelog.py
+++ b/util/build_scripts/dist-changelog.py
@@ -22,5 +22,6 @@ cmd = [
]
# MESON_PROJECT_DIST_ROOT is set only if meson.version() >= 0.58.0.
project_dist_root = os.getenv('MESON_PROJECT_DIST_ROOT', os.getenv('MESON_DIST_ROOT'))
-with open(os.path.join(project_dist_root, 'ChangeLog'), mode='w') as logfile:
+logfilename = os.path.join(project_dist_root, 'ChangeLog')
+with open(logfilename, mode='w', encoding='utf-8') as logfile:
sys.exit(subprocess.run(cmd, stdout=logfile).returncode)
diff --git a/util/build_scripts/generate-binding.py b/util/build_scripts/generate-binding.py
index 6d719ff..f426f0d 100755
--- a/util/build_scripts/generate-binding.py
+++ b/util/build_scripts/generate-binding.py
@@ -33,7 +33,7 @@ def generate_wrap_init():
'--namespace=' + namespace,
'--parent_dir=' + parent_dir,
] + sys.argv[5:]
- with open(output_file, mode='w') as output_file_obj:
+ with open(output_file, mode='w', encoding='utf-8') as output_file_obj:
return subprocess.run(cmd, stdout=output_file_obj).returncode
# Invoked from custom_target() in meson.build.
diff --git a/util/meson_aux/extra-dist-cmd.py b/util/meson_aux/extra-dist-cmd.py
index ff2c230..7ff676e 100755
--- a/util/meson_aux/extra-dist-cmd.py
+++ b/util/meson_aux/extra-dist-cmd.py
@@ -29,7 +29,8 @@ cmd = [
]
# MESON_PROJECT_DIST_ROOT is set only if meson.version() >= 0.58.0.
project_dist_root = os.getenv('MESON_PROJECT_DIST_ROOT', os.getenv('MESON_DIST_ROOT'))
-with open(os.path.join(project_dist_root, 'ChangeLog'), mode='w') as logfile:
+logfilename = os.path.join(project_dist_root, 'ChangeLog')
+with open(logfilename, mode='w', encoding='utf-8') as logfile:
result = subprocess.run(cmd, stdout=logfile)
# Distribute the libstdc++.tag file in addition to the files in the local git clone.