From 38597f81cf79385723d1c5872c0d1278f45f420f Mon Sep 17 00:00:00 2001 From: Goffi Date: Sun, 3 Jun 2018 18:05:01 +0200 Subject: [PATCH] jp (forums/edit): fixed unicode when dumping in json --- sat_frontends/jp/cmd_forums.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sat_frontends/jp/cmd_forums.py b/sat_frontends/jp/cmd_forums.py index e80471c7..83421403 100644 --- a/sat_frontends/jp/cmd_forums.py +++ b/sat_frontends/jp/cmd_forums.py @@ -24,6 +24,7 @@ from sat_frontends.jp.constants import Const as C from sat_frontends.jp import common from sat.tools.common.ansi import ANSI as A from functools import partial +import codecs import json __commands__ = ["Forums"] @@ -69,7 +70,9 @@ class Edit(base.CommandBase, common.BaseEdit): if forums_json: # we loads and dumps to have pretty printed json forums = json.loads(forums_json) - json.dump(forums, content_file_obj, ensure_ascii=False, indent=4) + # cf. https://stackoverflow.com/a/18337754 + f = codecs.getwriter('utf-8')(content_file_obj) + json.dump(forums, f, ensure_ascii=False, indent=4) content_file_obj.seek(0) self.runEditor("forums_editor_args", content_file_path, content_file_obj)