Philipp Hörist pushed to branch master at gajim / gajim
Commits: 7becee59 by lovetox at 2022-05-13T21:43:21+02:00 fix: Set encoding when calling open()
Otherwise the platform default will be taken, for example on Windows this is not utf8.
Fixes #10849
- - - - -
5 changed files:
- gajim/common/helpers.py - gajim/plugins/pluginmanager.py - scripts/dev/generate_ui_types.py - scripts/update_translations.py - test/gtk/util.py
Changes:
===================================== gajim/common/helpers.py ===================================== @@ -814,7 +814,7 @@ def load_json(path: Path, key: Optional[str] = None, default: Optional[Any] = None) -> Any: try: - with path.open('r') as file: + with path.open('r', encoding='utf8') as file: json_dict = json.loads(file.read()) except Exception: log.exception('Parsing error')
===================================== gajim/plugins/pluginmanager.py ===================================== @@ -109,7 +109,7 @@ def from_path(cls, path: Path) -> PluginManifest: return cls.from_manifest_ini(manifest_path)
if manifest_path.name == 'plugin-manifest.json': - with manifest_path.open() as f: + with manifest_path.open(encoding='utf8') as f: try: manifest = json.load(f) except Exception as error: @@ -124,7 +124,7 @@ def from_manifest_ini(cls, path: Path) -> PluginManifest: conf = configparser.ConfigParser() conf.remove_section('info')
- with path.open() as conf_file: + with path.open(encoding='utf8') as conf_file: try: conf.read_file(conf_file) except configparser.Error as error:
===================================== scripts/dev/generate_ui_types.py ===================================== @@ -80,7 +80,7 @@ def parse(path, file):
builder_names = []
-with out_path.open(mode='w') as file: +with out_path.open(mode='w', encoding='utf8') as file: file.write(IMPORTS) for path in paths: if path.name.endswith('~'):
===================================== scripts/update_translations.py ===================================== @@ -21,7 +21,7 @@
def template_is_equal(old_template_path: Path, new_template: str) -> bool: - with open(old_template_path, 'r') as f: + with open(old_template_path, 'r', encoding='utf8') as f: old_template = f.read()
pattern = r'"POT-Creation-Date: .*\n"' @@ -64,7 +64,7 @@ def update_translation_template() -> bool: # No new strings were discovered return False
- with open(TRANS_TEMPLATE, 'w') as f: + with open(TRANS_TEMPLATE, 'w', encoding='utf8') as f: f.write(template) return True
===================================== test/gtk/util.py ===================================== @@ -11,7 +11,7 @@ def get_gajim_dir(): def load_style(filename, priority): path = get_gajim_dir() / 'data' / 'style' / filename try: - with open(str(path), "r") as file: + with open(str(path), 'r', encoding='utf8') as file: css = file.read() except Exception as exc: print(exc)
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/7becee59338bddf3c31a15165e2e02864...