Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 22cd768

Browse files
committed
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.
1 parent db2a902 commit 22cd768

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Lib/posixfile.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,16 @@ def open(self, name, mode='r', bufsize=-1):
7575
return self.fileopen(__builtin__.open(name, mode, bufsize))
7676

7777
def fileopen(self, file):
78+
import types
7879
if `type(file)` != "<type 'file'>":
7980
raise TypeError, 'posixfile.fileopen() arg must be file object'
8081
self._file_ = file
8182
# Copy basic file methods
82-
for method in file.__methods__:
83-
setattr(self, method, getattr(file, method))
83+
for maybemethod in dir(file):
84+
if not maybemethod.startswith('_'):
85+
attr = getattr(file, maybemethod)
86+
if isinstance(attr, types.BuiltinMethodType):
87+
setattr(self, maybemethod, attr)
8488
return self
8589

8690
#

0 commit comments

Comments
 (0)