[mod_python] Point of frustration/disappointment

Graham Dumpleton grahamd at dscpl.com.au
Fri Jul 29 00:38:59 EDT 2005


Jim Gallacher wrote ..
> Jim Popovitch wrote:
> > On Thu, 2005-07-28 at 23:08 -0400, Jack Diederich wrote:
> > 
> >>On Thu, Jul 28, 2005 at 09:18:10PM -0400, Jim Popovitch wrote:
> >>
> >>>Well, now that it compiles cleanly... guess what...  I've run into the
> >>>(in)famous "cannot unmarshal code objects in restricted execution mode"
> >>>error for which google reveals years worth of past pleas for mod_python
> >>>to address.  I guess I'm not alone in my frustration and disappointment:
> >>>
> >>
> >>rexec was completely ineffective and was declared dangerous in the 2.2
> >>timeframe (I think it was yanked in 2.3).  
> > 
> > 
> > v2.3 of mod_python or Python?
> 
> Python. See http://www.python.org/doc/2.3/lib/module-rexec.html

The sort of error related to "restricted execution mode" is in all
likelihood has got nothing to do with the "rexec" module. The checks for
whether Python thinks it is running in restricted execution mode are
much more low level than that. One can get these sort of problems in
code totally unrelated to the "rexec" module.

I can't remember exactly, but what it all boils down to is that if a
module replaces the "__builtins__" within its own global namespace with
something that is different to "__builtin__.__dict__" then Python will
set an internal flag associated with the execution context for that
thread which says it is running in "restricted execution mode".

When in this mode any code which is executed which can't run in
restricted execution mode will raise some sort of error like above. This
specific error above isn't the only error that can occur.

 I once managed to create a half dozen line program which would
illustrate this in action, but can't find it now and can't remember what
I did to trigger it. :-(

Thus, one possibility is whether the package the problem occurs in
fiddles with __builtins__ at all.

Anyway, if I find the test program which shows the problem or if I can
work it out again, I'll post it.

Graham



More information about the Mod_python mailing list