diff options
author | Gustavo Niemeyer <gustavo@niemeyer.net> | 2002-12-16 13:11:57 (GMT) |
---|---|---|
committer | Gustavo Niemeyer <gustavo@niemeyer.net> | 2002-12-16 13:11:57 (GMT) |
commit | d5ae01a8037d5cba917aef531a3281760e82ed77 (patch) | |
tree | a610da98e483885db7363f1b28fa9c1af0c5e48c /Lib/rexec.py | |
parent | 822a77fcc761b3c9992950ddf48b3f0bec917b4d (diff) | |
download | cpython-d5ae01a8037d5cba917aef531a3281760e82ed77.zip cpython-d5ae01a8037d5cba917aef531a3281760e82ed77.tar.gz cpython-d5ae01a8037d5cba917aef531a3281760e82ed77.tar.bz2 |
Applying patch
[#636769] Fix for major rexec bugs
* Lib/rexec.py
(FileBase): Added 'xreadlines' and '__iter__' to allowed file methods.
(FileWrapper.__init__): Removed unnecessary self.f variable, which gave
direct access to the file object.
(RExec): Added 'xreadlines' and '_weakref' to allowed modules.
(RExec.r_open): Convert string subclasses to a real string classes
before doing comparisons with mode parameter.
* Lib/ihooks.py
(BasicModuleImporter.import_module/reload/unload): Convert the module
name to a real string before working with it.
(ModuleImporter.import_module/import_it/reload): Convert the module
name to a real strings before working with it.
* Misc/NEWS
Document the change.
Diffstat (limited to 'Lib/rexec.py')
-rw-r--r-- | Lib/rexec.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/rexec.py b/Lib/rexec.py index d399545..b1a1427 100644 --- a/Lib/rexec.py +++ b/Lib/rexec.py @@ -29,7 +29,8 @@ __all__ = ["RExec"] class FileBase: ok_file_methods = ('fileno', 'flush', 'isatty', 'read', 'readline', - 'readlines', 'seek', 'tell', 'write', 'writelines') + 'readlines', 'seek', 'tell', 'write', 'writelines', 'xreadlines', + '__iter__') class FileWrapper(FileBase): @@ -37,7 +38,6 @@ class FileWrapper(FileBase): # XXX This is just like a Bastion -- should use that! def __init__(self, f): - self.f = f for m in self.ok_file_methods: if not hasattr(self, m) and hasattr(f, m): setattr(self, m, getattr(f, m)) @@ -137,7 +137,8 @@ class RExec(ihooks._Verbose): 'cmath', 'errno', 'imageop', 'marshal', 'math', 'md5', 'operator', 'parser', 'regex', 'pcre', 'rotor', 'select', - 'sha', '_sre', 'strop', 'struct', 'time') + 'sha', '_sre', 'strop', 'struct', 'time', + 'xreadlines', '_weakref') ok_posix_names = ('error', 'fstat', 'listdir', 'lstat', 'readlink', 'stat', 'times', 'uname', 'getpid', 'getppid', @@ -515,6 +516,7 @@ class RExec(ihooks._Verbose): used to change the policies enforced by a restricted environment. """ + mode = str(mode) if mode not in ('r', 'rb'): raise IOError, "can't open files for writing in restricted mode" return open(file, mode, buf) |