Commit 7044e206 authored by Sébastien Luttringer's avatar Sébastien Luttringer

improve exceptions in string2module

parent 1fa9f682
...@@ -671,7 +671,7 @@ def render_templates(target, context, tpl_ext=".istpl", force=False, keep=False) ...@@ -671,7 +671,7 @@ def render_templates(target, context, tpl_ext=".istpl", force=False, keep=False)
if not keep: if not keep:
os.unlink(tpl_path) os.unlink(tpl_path)
def string2module(name, code, filename): def string2module(name, string, filename):
''' '''
Create a python module from a string Create a python module from a string
''' '''
...@@ -679,10 +679,12 @@ def string2module(name, code, filename): ...@@ -679,10 +679,12 @@ def string2module(name, code, filename):
module = imp.new_module(name) module = imp.new_module(name)
# compile module code # compile module code
try: try:
bytecode = compile(code, filename, "exec") bytecode = compile(string, filename, "exec")
except Exception as e: except Exception as e:
raise ISError(u"Unable to compile %s fail: %s" % raise ISError(u"Unable to compile %s" % filename, e)
(filename, e)) # Load module
# fill module try:
exec bytecode in module.__dict__ exec bytecode in module.__dict__
except Exception as e:
raise ISError(u"Unable to load %s" % filename, e)
return module return module
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment