[Python-checkins] python/dist/src/Lib rexec.py,1.45,1.46 ihooks.py,1.14,1.15
niemeyer@users.sourceforge.net
niemeyer@users.sourceforge.net
2002年12月16日 05:11:59 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv3036/Lib
Modified Files:
rexec.py ihooks.py
Log Message:
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.
Index: rexec.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/rexec.py,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** rexec.py 11 Oct 2002 16:20:45 -0000 1.45
--- rexec.py 16 Dec 2002 13:11:55 -0000 1.46
***************
*** 30,34 ****
ok_file_methods = ('fileno', 'flush', 'isatty', 'read', 'readline',
! 'readlines', 'seek', 'tell', 'write', 'writelines')
--- 30,35 ----
ok_file_methods = ('fileno', 'flush', 'isatty', 'read', 'readline',
! 'readlines', 'seek', 'tell', 'write', 'writelines', 'xreadlines',
! '__iter__')
***************
*** 38,42 ****
def __init__(self, f):
- self.f = f
for m in self.ok_file_methods:
if not hasattr(self, m) and hasattr(f, m):
--- 39,42 ----
***************
*** 138,142 ****
'marshal', 'math', 'md5', 'operator',
'parser', 'regex', 'pcre', 'rotor', 'select',
! 'sha', '_sre', 'strop', 'struct', 'time')
ok_posix_names = ('error', 'fstat', 'listdir', 'lstat', 'readlink',
--- 138,143 ----
'marshal', 'math', 'md5', 'operator',
'parser', 'regex', 'pcre', 'rotor', 'select',
! 'sha', '_sre', 'strop', 'struct', 'time',
! 'xreadlines', '_weakref')
ok_posix_names = ('error', 'fstat', 'listdir', 'lstat', 'readlink',
***************
*** 516,519 ****
--- 517,521 ----
"""
+ mode = str(mode)
if mode not in ('r', 'rb'):
raise IOError, "can't open files for writing in restricted mode"
Index: ihooks.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/ihooks.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** ihooks.py 1 Jun 2002 14:18:45 -0000 1.14
--- ihooks.py 16 Dec 2002 13:11:56 -0000 1.15
***************
*** 353,356 ****
--- 353,357 ----
def import_module(self, name, globals={}, locals={}, fromlist=[]):
+ name = str(name)
if name in self.modules:
return self.modules[name] # Fast path
***************
*** 361,365 ****
def reload(self, module, path = None):
! name = module.__name__
stuff = self.loader.find_module(name, path)
if not stuff:
--- 362,366 ----
def reload(self, module, path = None):
! name = str(module.__name__)
stuff = self.loader.find_module(name, path)
if not stuff:
***************
*** 368,372 ****
def unload(self, module):
! del self.modules[module.__name__]
# XXX Should this try to clear the module's namespace?
--- 369,373 ----
def unload(self, module):
! del self.modules[str(module.__name__)]
# XXX Should this try to clear the module's namespace?
***************
*** 395,399 ****
def import_module(self, name, globals=None, locals=None, fromlist=None):
parent = self.determine_parent(globals)
! q, tail = self.find_head_package(parent, name)
m = self.load_tail(q, tail)
if not fromlist:
--- 396,400 ----
def import_module(self, name, globals=None, locals=None, fromlist=None):
parent = self.determine_parent(globals)
! q, tail = self.find_head_package(parent, str(name))
m = self.load_tail(q, tail)
if not fromlist:
***************
*** 481,487 ****
--- 482,490 ----
except AttributeError:
return None
+ partname = str(partname)
stuff = self.loader.find_module(partname, path)
if not stuff:
return None
+ fqname = str(fqname)
m = self.loader.load_module(fqname, stuff)
if parent:
***************
*** 490,494 ****
def reload(self, module):
! name = module.__name__
if '.' not in name:
return self.import_it(name, name, None, force_load=1)
--- 493,497 ----
def reload(self, module):
! name = str(module.__name__)
if '.' not in name:
return self.import_it(name, name, None, force_load=1)