diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2021-06-22 22:59:16 +0200 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2021-06-29 11:28:08 +0200 |
commit | 3e396b3782813d36d46195564cd0e111422bcaf5 (patch) | |
tree | f315e990f71984745fcb8f22dac2f0e400fecadb /mesonbuild/templates/ctemplates.py | |
parent | 28175bbee2c111cf41b80c97bbadd7dbabaa8990 (diff) | |
download | meson-3e396b3782813d36d46195564cd0e111422bcaf5.zip meson-3e396b3782813d36d46195564cd0e111422bcaf5.tar.gz meson-3e396b3782813d36d46195564cd0e111422bcaf5.tar.bz2 |
fix: Always explicitly set encoding for text files (fixes #8263)
Diffstat (limited to 'mesonbuild/templates/ctemplates.py')
-rw-r--r-- | mesonbuild/templates/ctemplates.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/mesonbuild/templates/ctemplates.py b/mesonbuild/templates/ctemplates.py index 440731c..9b651bc 100644 --- a/mesonbuild/templates/ctemplates.py +++ b/mesonbuild/templates/ctemplates.py @@ -132,11 +132,12 @@ class CProject(SampleImpl): def create_executable(self) -> None: lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower()) source_name = lowercase_token + '.c' - open(source_name, 'w').write(hello_c_template.format(project_name=self.name)) - open('meson.build', 'w').write(hello_c_meson_template.format(project_name=self.name, - exe_name=lowercase_token, - source_name=source_name, - version=self.version)) + open(source_name, 'w', encoding='utf-8').write(hello_c_template.format(project_name=self.name)) + open('meson.build', 'w', encoding='utf-8').write( + hello_c_meson_template.format(project_name=self.name, + exe_name=lowercase_token, + source_name=source_name, + version=self.version)) def create_library(self) -> None: lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower()) @@ -159,7 +160,7 @@ class CProject(SampleImpl): 'test_name': lowercase_token, 'version': self.version, } - open(lib_h_name, 'w').write(lib_h_template.format(**kwargs)) - open(lib_c_name, 'w').write(lib_c_template.format(**kwargs)) - open(test_c_name, 'w').write(lib_c_test_template.format(**kwargs)) - open('meson.build', 'w').write(lib_c_meson_template.format(**kwargs)) + open(lib_h_name, 'w', encoding='utf-8').write(lib_h_template.format(**kwargs)) + open(lib_c_name, 'w', encoding='utf-8').write(lib_c_template.format(**kwargs)) + open(test_c_name, 'w', encoding='utf-8').write(lib_c_test_template.format(**kwargs)) + open('meson.build', 'w', encoding='utf-8').write(lib_c_meson_template.format(**kwargs)) |