__builtins__ thread-safe / __builtins__ as function?
rosuav at gmail.com
Thu Oct 11 16:25:27 CEST 2012
On Fri, Oct 12, 2012 at 1:16 AM, Juergen Bartholomae
<bartholomae.juergen at googlemail.com> wrote:
> One possible solution is to somehow redirect every __builtins__ to a
> function that returns a different __builtins__ dictionary for each thread
> (such a function already exists).
How exactly does the code reference it? If they're simply referring to
the name __builtins__ at module level, you ought to be able to import
the module, then assign some_module.__builtins__ to your thread-local
object, then call code in it as normal.
An interesting problem, and one where monkeypatching is, imho, justified.
More information about the Python-list