diff --git a/modules/python/generator/visp_python_bindgen/generator.py b/modules/python/generator/visp_python_bindgen/generator.py index 5b80634664..a8b8aea0e5 100644 --- a/modules/python/generator/visp_python_bindgen/generator.py +++ b/modules/python/generator/visp_python_bindgen/generator.py @@ -138,7 +138,7 @@ def generate_module(generate_path: Path, config_path: Path) -> None: # Step 3: write to main.cpp the call to the submodule binding implementations. main_path = generate_path / 'main.cpp' - with open(main_path, 'w') as main_file: + with open(main_path, 'w', encoding='utf-8') as main_file: submodule_fn_declarations = [] submodule_fn_calls = [] for submodule in submodules: diff --git a/modules/python/generator/visp_python_bindgen/header.py b/modules/python/generator/visp_python_bindgen/header.py index 0bd3ab3ce9..4b7ff3c1e6 100644 --- a/modules/python/generator/visp_python_bindgen/header.py +++ b/modules/python/generator/visp_python_bindgen/header.py @@ -153,7 +153,7 @@ def run_preprocessor(self): # if 'visp3' in matches.group() or 'opencv' in matches.group(): # tmp_file_content.append(line) - with open(tmp_file_path.absolute(), 'w') as tmp_file: + with open(tmp_file_path.absolute(), 'w', encoding='utf-8') as tmp_file: tmp_file.write(''.join(tmp_file_content)) tmp_file.flush() diff --git a/modules/python/generator/visp_python_bindgen/submodule.py b/modules/python/generator/visp_python_bindgen/submodule.py index 67146fad32..5d373bc817 100644 --- a/modules/python/generator/visp_python_bindgen/submodule.py +++ b/modules/python/generator/visp_python_bindgen/submodule.py @@ -81,7 +81,7 @@ def _get_config_file_or_create_default(self, path: Path) -> Dict: 'enums': {}, 'config_includes': [] } - with open(path, 'w') as config_file: + with open(path, 'w', encoding='utf-8') as config_file: json.dump(default_config, config_file) return default_config else: @@ -195,7 +195,7 @@ def generate(self) -> None: {bindings} }} ''' - with open(self.submodule_file_path, 'w') as submodule_file: + with open(self.submodule_file_path, 'w', encoding='utf-8') as submodule_file: submodule_file.write(format_str) logs_path = self.submodule_file_path.parent.parent / 'logs'