[Python-checkins] CVS: python/dist/src/Lib posixfile.py,1.22,1.23

Tim Peters tim_one@users.sourceforge.net
Mon, 17 Sep 2001 22:40:26 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv6382/python/Lib

Modified Files:
	posixfile.py 
Log Message:
This module didn't work at all anymore -- blew up with AttributeError
on file.__methods__.  Since the docs say "This module will become obsolete
in a future release", this is just a quick hack to stop it from blowing
up.  If you care about this module, test it!  It doesn't make much sense
on Windows.


Index: posixfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/posixfile.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** posixfile.py	2001/08/13 14:47:12	1.22
--- posixfile.py	2001/09/18 05:40:24	1.23
***************
*** 76,85 ****
  
      def fileopen(self, file):
          if `type(file)` != "<type 'file'>":
              raise TypeError, 'posixfile.fileopen() arg must be file object'
          self._file_  = file
          # Copy basic file methods
!         for method in file.__methods__:
!             setattr(self, method, getattr(file, method))
          return self
  
--- 76,89 ----
  
      def fileopen(self, file):
+         import types
          if `type(file)` != "<type 'file'>":
              raise TypeError, 'posixfile.fileopen() arg must be file object'
          self._file_  = file
          # Copy basic file methods
!         for maybemethod in dir(file):
!             if not maybemethod.startswith('_'):
!                 attr = getattr(file, maybemethod)
!                 if isinstance(attr, types.BuiltinMethodType):
!                     setattr(self, maybemethod, attr)
          return self