def test_getbuiltins(self, space): assert PyEval_GetBuiltins(space) is space.builtin.w_dict def cpybuiltins(space): return PyEval_GetBuiltins(space) w_cpybuiltins = space.wrap(interp2app(cpybuiltins)) w_result = space.appexec([w_cpybuiltins], """(cpybuiltins): return cpybuiltins() is __builtins__.__dict__ """) assert space.is_true(w_result) w_result = space.appexec([w_cpybuiltins], """(cpybuiltins): d = dict(__builtins__={'len':len}, cpybuiltins=cpybuiltins) return eval("cpybuiltins()", d, d) """) assert space.len_w(w_result) == 1
def cpybuiltins(space): return PyEval_GetBuiltins(space)