From c7ccdde0c995a31863581cb4fd48b329bf4bf048 Mon Sep 17 00:00:00 2001 From: Goffi Date: Sun, 24 Sep 2017 16:29:18 +0200 Subject: [PATCH] jp (pubsub/node/schema): check that a schema exists before parsing it (fix issue on new schema edition) --- frontends/src/jp/cmd_pubsub.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontends/src/jp/cmd_pubsub.py b/frontends/src/jp/cmd_pubsub.py index e65046e9..7fb27c8b 100644 --- a/frontends/src/jp/cmd_pubsub.py +++ b/frontends/src/jp/cmd_pubsub.py @@ -420,11 +420,13 @@ class NodeSchemaEdit(base.CommandBase, common.BaseEdit): except ImportError: self.disp(u"lxml module must be installed to use edit, please install it with \"pip install lxml\"", error=True) self.host.quit(1) - parser = etree.XMLParser(remove_blank_text=True) - schema_elt = etree.fromstring(schema, parser) content_file_obj, content_file_path = self.getTmpFile() - content_file_obj.write(etree.tostring(schema_elt, encoding="utf-8", pretty_print=True)) - content_file_obj.seek(0) + schema = schema.strip() + if schema: + parser = etree.XMLParser(remove_blank_text=True) + schema_elt = etree.fromstring(schema, parser) + content_file_obj.write(etree.tostring(schema_elt, encoding="utf-8", pretty_print=True)) + content_file_obj.seek(0) self.runEditor("pubsub_schema_editor_args", content_file_path, content_file_obj) def start(self):