Re: Safe-Python?

lance@fox.com
Tue, 27 Sep 94 16:59:59 PDT

I have sent this to Guido, but have not gotten his response so I thought
I would post to the net.

One of the biggest problems with making a safe-python as far as I see it
is that there is only one interpreter with only one main name space.

The ONLY thing that I liked about Tcl is that you can create new interpreter
instances and add your own functions to it.

What I propose for a safe-python will take some work, but I do not think
it is beyond what needs to be done.
I propose that python is modified to use Interpreter Objects.

What would need to be done is to modify the core parts of Python to work
with a object as it's calling environment and allow execution to be started
in other objects using different intreperter objects.

How would you make a "Safe" Python program then? Simple.

You create a 'host' program. This program creates a new interpreter object
for each connection from a remote site (in the case of network passing
of code objects). The 'host' program then sets up the interpreter object
to a state that it knows. This may include overriding the builtin commands
or statements (like import) with functions that the programer writes.
The host program may also remove builtin functions or statements instead
of overriding them.

Then when the host program gets a code object, it would call something
like this:

co = <code object from net to be executed locally>
io = <interpreter object created and set up by host program>

io.exec(co) # This executes the code object in the context of the interpreter
# object, and returns the result.

If you wanted to execute a specific function that is in the interpreter object
you might use a call similar to:

io.call('function name', arg1, arg2, arg3,.....)

There are probably a lot of holes in this idea, but please feel free to
point them out...

--
Lance Ellinghouse                lance@fox.com
PGP 2.6 Key fingerprint =  94 A0 AA 66 2E 6D B1 DC  63 C6 FD F0 C1 66 1C 61 
To get PGP 2.6 Public Key, send email to: pgp-key@fox.com