'Return the module in which this function is supposed to exist.
This may be a dummy module if the function was dynamically
generated.'

def lookup_module(self):

    if (self.modname == _dynamic_modname):
        return _dynamic_module
    else:
        return sys.modules[self.modname]
