From 7044e2062fed984cf91509b9d689493b5543a3f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Luttringer?= Date: Thu, 21 Jun 2012 13:28:12 +0200 Subject: [PATCH] improve exceptions in string2module --- installsystems/tools.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/installsystems/tools.py b/installsystems/tools.py index 11d1de2..dee8ea9 100644 --- a/installsystems/tools.py +++ b/installsystems/tools.py @@ -671,7 +671,7 @@ def render_templates(target, context, tpl_ext=".istpl", force=False, keep=False) if not keep: os.unlink(tpl_path) -def string2module(name, code, filename): +def string2module(name, string, filename): ''' Create a python module from a string ''' @@ -679,10 +679,12 @@ def string2module(name, code, filename): module = imp.new_module(name) # compile module code try: - bytecode = compile(code, filename, "exec") + bytecode = compile(string, filename, "exec") except Exception as e: - raise ISError(u"Unable to compile %s fail: %s" % - (filename, e)) - # fill module - exec bytecode in module.__dict__ + raise ISError(u"Unable to compile %s" % filename, e) + # Load module + try: + exec bytecode in module.__dict__ + except Exception as e: + raise ISError(u"Unable to load %s" % filename, e) return module -- GitLab