You need to determine why the builtins in main_dict are not the same as the interpreter's builtins -- this is the reason for "restricted execution mode". ./Objects/frameobject.c: f->f_restricted = (builtins != tstate->interp->builtins); Jeff