Implement import_buffer_to_module

This commit is contained in:
John Jacobsen 2013-04-24 09:21:16 -04:00 committed by Will Kahn-Greene
parent 50daf1b4c8
commit 760774afde
1 changed files with 7 additions and 0 deletions

View File

@ -78,6 +78,13 @@ def import_file_to_module(module_name, fpath):
return mod
def import_buffer_to_module(module_name, buf):
_ast = import_buffer_to_ast(buf)
mod = imp.new_module(module_name)
eval(ast_compile(_ast, "", "exec"), mod.__dict__)
return mod
def hy_eval(hytree, namespace):
foo = HyObject()
foo.start_line = 0