Exemplo n.º 1
0
def compileModule(module, registry, source):
    # Try to prevent compilation errors from files without trailing newlines.
    if source and source[-1] != "\n":
        source += "\n"
    module._p_changed = True
    moddict = module.__dict__
    old_names = NameFinder(module)
    moddict[__persistent_module_registry__] = registry
    # XXX need to be able to replace sys.std{in,out,err} at this point
    exec source in moddict
    # XXX and restore them here.
    del moddict[__persistent_module_registry__]
    new_names = NameFinder(module)
    replacements = new_names.replacements(old_names)
    convert(module, replacements)