mario ruggier <mario.rugg...@gmail.com> writes: > 2009-01-15 22:26:18,704 ERROR [evoque] AttributeError: 'function' > object has no attribute 'func_globals': File "<string>", line 1, in > <module>
Damn. So that doesn't work. :-( > But even if inspect did have the func_globals attribute, the "open" > builtin will not be found on __builtins__ (that is cleaned out when > restricted=True). Irrelevant. I wasn't trying to get at my __builtins__ but the one attached to a function I was passed in, which has a different environment. You define a function (a method, actually, but it matters little). The function's globals dictionary is attached as an attribute. You didn't do anything special here, so the globals have the standard __builtins__ binding. It contains open. You now run my code in a funny environment with a stripped-down __builtins__. But that doesn't matter, because my environment contains your function. And that function has your __builtins__ hanging off the side of it. ... but I can't actually get there because of f_restricted. You don't mention the fact that Python magically limits access to these attributes if __builtins__ doesn't match the usual one, so I think you got lucky. -- [mdw] -- http://mail.python.org/mailman/listinfo/python-list