Skip to content

Commit 1caa072

Browse files
committed
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.)
1 parent b6e835c commit 1caa072

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Lib/rexec.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ def copy_none(self, src):
261261
# Add a module -- return an existing module or create one
262262

263263
def add_module(self, mname):
264-
if self.modules.has_key(mname):
265-
return self.modules[mname]
266-
self.modules[mname] = m = self.hooks.new_module(mname)
264+
m = self.modules.get(mname)
265+
if m is None:
266+
self.modules[mname] = m = self.hooks.new_module(mname)
267267
m.__builtins__ = self.modules['__builtin__']
268268
return m
269269

0 commit comments

Comments
 (0)