def execute_function(self, func, *nargs, **kwargs):
<EOL>import types<EOL>fn = types.FunctionType(func.__code__,<EOL>func.__globals__.copy(),<EOL>name=func.__name__,<EOL>argdefs=func.__defaults__,<EOL>closure=func.__closure__)<EOL>fn.__globals__.update(self.globals)<EOL>error_class = Exception if config.catch_rex_errors else None<EOL>try:<EOL><INDENT>return fn(*nargs, **kwargs)<EOL><DEDENT>except RexError:<EOL><INDENT>raise<EOL><DEDENT>except error_class as e:<EOL><INDENT>from inspect import getfile<EOL>stack = traceback.format_exc()<EOL>filename = getfile(func)<EOL>raise RexError("<STR_LIT>" % (filename, stack))<EOL><DEDENT>
Execute a function object within the execution context.
@returns The result of the function call.