Embedding Python in Python

JCM joshway_without_spam at myway.com
Fri Oct 10 17:02:36 EDT 2003


Cameron Laird <claird at lairds.com> wrote:
...
> I'm surprised--astounded, in fact--that those more expert
> with Python than I haven't already jumped in to correct
> errors that seem to be arising in this thread.

What errors?

> Yes, we all count on the Python interpreter to toss excep-
> tions when it's unhappy, *not* "to gasp and die".  There
> are a few situations it can't handle, but only few.

The original question was about ensuring users write code which is,
by some definition, safe.  For example, you don't want users calling
"os.system('rm -rf /')".  You also don't want them overriding
builtins.

> There's a lot to say on the subject of interpretation of
> code supplied by users.  In particular, the three Python
> projects
>   rexec
>   Bastion
>   RestrictedPython
> all address this requirement on a technical level.  If 
> your goal is a useful working application, I strongly 
> urge you to read up on these.  Correct construction on
> your own of a "blacklist" is ... difficult.

I'm under the impression that the rexec and Bastion modules do not
work with Python 2.3+.  I'm not familiar with RestrictedPython.




More information about the Python-list mailing list