Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlovetox <philipp@hoerist.com>2022-05-13 22:43:21 +0300
committerlovetox <philipp@hoerist.com>2022-05-13 22:43:21 +0300
commit7becee59338bddf3c31a15165e2e028649f624e1 (patch)
tree69d340bb480b69a957378842d8d5534d67413409
parenta86e178a3c72e00b99c2af302ce8cfa5245f53ee (diff)
fix: Set encoding when calling open()
Otherwise the platform default will be taken, for example on Windows this is not utf8. Fixes #10849
-rw-r--r--gajim/common/helpers.py2
-rw-r--r--gajim/plugins/pluginmanager.py4
-rwxr-xr-xscripts/dev/generate_ui_types.py2
-rw-r--r--scripts/update_translations.py4
-rw-r--r--test/gtk/util.py2
5 files changed, 7 insertions, 7 deletions
diff --git a/gajim/common/helpers.py b/gajim/common/helpers.py
index a599212bd..15e2b480f 100644
--- a/gajim/common/helpers.py
+++ b/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')
diff --git a/gajim/plugins/pluginmanager.py b/gajim/plugins/pluginmanager.py
index 4f61377fc..26e42d761 100644
--- a/gajim/plugins/pluginmanager.py
+++ b/gajim/plugins/pluginmanager.py
@@ -109,7 +109,7 @@ class 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 @@ class 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:
diff --git a/scripts/dev/generate_ui_types.py b/scripts/dev/generate_ui_types.py
index 2e770e9fb..928764e07 100755
--- a/scripts/dev/generate_ui_types.py
+++ b/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('~'):
diff --git a/scripts/update_translations.py b/scripts/update_translations.py
index 678057417..4574dd8ef 100644
--- a/scripts/update_translations.py
+++ b/scripts/update_translations.py
@@ -21,7 +21,7 @@ TRANSLATABLE_FILES = [
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
diff --git a/test/gtk/util.py b/test/gtk/util.py
index d09a573cb..9ecd50ece 100644
--- a/test/gtk/util.py
+++ b/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)