Non-secure execution environment

rogeeff at gmail.com rogeeff at gmail.com
Fri Apr 17 12:28:54 EDT 2009


On Apr 17, 3:16 am, Ken Seehart <k... at seehart.com> wrote:
> roge... at gmail.com wrote:
> > Hi,
>
> > I am C++ guy for the most part and don't know much of Python, so,
> > please, bear with me if I am asking errrm..idiotic question.
>
> > Old rexec module provided kinda 'secure' execution environment. I am
> > not looking for security at this point. What I need an execution
> > environment which almost like rexec, but is non-secure.
> >   What I want is:
> >   separate global dictionary,
> >   separate list of imported modules,
> >   separate sys.path
> >   (optionaly) separate __builtins__

> As far as I know, you can't make multiple instances of the python
> environment from within python,

How about rexec? It's almost there. It just enforces some restrictions
I do not need. The problem as I see it is that I need custom import
operator to maintain separate "imported modules" list. The custom
import required separate __builtins__ dictionary and that cause the
Python C implementation to choke on access to the restricted
attributes.

Would I be able to have custom import without updating builtins, I'd
get what I need. But I do not know how to achieve this.

> but there is an easier way to get what
> you want, given that this is an embedding situation.

> See:http://wingware.com/psupport/python-manual/1.5/api/initialization.html

I am using Python 2.4, if it's matter

> You can use Py_NewInterpreter() to create multiple instances of python,
> which should give you the desired effect (though I have not tried this).

What do I do with pointer generated by this function? How do I execute
anything inside this interpreter?

Also I am not sure how will this work with Boost.Python I am
employing.

Gennadiy



More information about the Python-list mailing list