]> granicus.if.org Git - python/commitdiff
This module didn't work at all anymore -- blew up with AttributeError
authorTim Peters <tim.peters@gmail.com>
Tue, 18 Sep 2001 05:40:24 +0000 (05:40 +0000)
committerTim Peters <tim.peters@gmail.com>
Tue, 18 Sep 2001 05:40:24 +0000 (05:40 +0000)
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.

Lib/posixfile.py

index 589510d55edd0133591666abb1e2907fbcad6cc5..dcd65cd69d088f76e5ad9174ca153ef07ad6b745 100644 (file)
@@ -75,12 +75,16 @@ class _posixfile_:
         return self.fileopen(__builtin__.open(name, mode, bufsize))
 
     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 method in file.__methods__:
-            setattr(self, method, getattr(file, method))
+        for maybemethod in dir(file):
+            if not maybemethod.startswith('_'):
+                attr = getattr(file, maybemethod)
+                if isinstance(attr, types.BuiltinMethodType):
+                    setattr(self, maybemethod, attr)
         return self
 
     #