[Python-checkins] python/dist/src/Lib rexec.py,1.34.10.2,1.34.10.3
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Sat, 14 Sep 2002 23:08:30 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv26563
Modified Files:
Tag: release22-maint
rexec.py
Log Message:
Backport (the relevant part of) rexec.py 1.41.
Address SF bug #577530: del __builtins__ breaks out of rexec
Using the suggestion there: add_module() forces __builtin__ back; this
fixes r_exec, r_eval, r_execfile.
This does not mean that rexec is now considered safe! But for those
willing to take the risk, it's safer than before. (Note that a safety
analysis of the code module would be wise if you plan to use the
interactive console for real -- I've only ever used it to play with
restricted mode.)
Index: rexec.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/rexec.py,v
retrieving revision 1.34.10.2
retrieving revision 1.34.10.3
diff -C2 -d -r1.34.10.2 -r1.34.10.3
*** rexec.py 31 May 2002 21:17:53 -0000 1.34.10.2
--- rexec.py 15 Sep 2002 06:08:27 -0000 1.34.10.3
***************
*** 289,295 ****
def add_module(self, mname):
! if self.modules.has_key(mname):
! return self.modules[mname]
! self.modules[mname] = m = self.hooks.new_module(mname)
m.__builtins__ = self.modules['__builtin__']
return m
--- 289,295 ----
def add_module(self, mname):
! m = self.modules.get(mname)
! if m is None:
! self.modules[mname] = m = self.hooks.new_module(mname)
m.__builtins__ = self.modules['__builtin__']
return m