bug with file object
I passed a file() to OleFileIO() and got an error in this line 979: filesize = os.path.getsize(filename) but in line 847 you check for a file object if hasattr(filename, 'read'):
- use name method of file object before calling getsize (only works with real files)
- use seek(os.SEEK_END) then tell (only works with seekable file objects)
- do not allow file-like objects
- read all data then check len
I think the seek/tell solution is the most appropriate, since other parts of the code require seekable file objects anyway. Non-seekable file objects could be read into memory and converted to a StringIO beforehand.