[mm-common] Python scripts: Specify file encoding
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mm-common] Python scripts: Specify file encoding
- Date: Sat, 17 Jul 2021 10:24:38 +0000 (UTC)
commit 43e37bd7591c7df340191c1f9c8aafd17751aa0b
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Sat Jul 17 12:19:58 2021 +0200
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.
util/build_scripts/dist-changelog.py | 3 ++-
util/build_scripts/generate-binding.py | 2 +-
util/meson_aux/extra-dist-cmd.py | 3 ++-
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.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]