Skip to content

Commit

Permalink
Set input encoding to UTF-8 to fix parsing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
SamFlt committed Sep 25, 2024
1 parent b2d0ca3 commit 921d9eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions modules/python/generator/visp_python_bindgen/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def run_preprocessor(self):
tmp_file_content.append(f'#include <{include}>\n')

# Remove all includes: we only include configuration headers, defined above
with open(self.path.absolute(), 'r') as input_header_file:
with open(self.path.absolute(), 'r', encoding='utf-8') as input_header_file:
include_regex = '#include\s*<(.*)>'
for line in input_header_file.readlines():
matches = re.search(include_regex, line)
Expand All @@ -167,7 +167,7 @@ def run_preprocessor(self):
preprocessed_header_content = None

# Remove all #defines that could have been left by the preprocessor
with open(preprocessor_output_path, 'r') as header_file:
with open(preprocessor_output_path, 'r', encoding='utf-8') as header_file:
preprocessed_header_lines = []
for line in header_file.readlines():
if not line.startswith('#define'):
Expand Down
4 changes: 2 additions & 2 deletions modules/python/generator/visp_python_bindgen/submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ def _get_config_file_or_create_default(self, path: Path) -> Dict:
json.dump(default_config, config_file)
return default_config
else:
with open(path, 'r') as config_file:
with open(path, 'r', encoding='utf-8') as config_file:
config = json.load(config_file)
for included_config_filename in config.get('config_includes', []):
included_config_path: Path = path.parent / included_config_filename
if not included_config_path.exists():
raise RuntimeError(f'Sub config file {included_config_path} does not exist')
logging.info(f'Trying to load subconfig file: {included_config_path}')
with open(included_config_path, 'r') as additional_config_file:
with open(included_config_path, 'r', encoding='utf-8') as additional_config_file:
additional_config = json.load(additional_config_file)
self.add_subconfig_file(config, additional_config)

Expand Down

0 comments on commit 921d9eb

Please sign in to comment.