Hi, What's meant exactly by a "file object"?
Let me be more specific: for example, pickle.dump() accepts a "file object". Looking at the code, it doesn't check the return value of its write() method. So it assumes that write() should always write the whole data (not partial write). Same thing for read, it assumes there won't be short reads. A sample use case would be passing a socket.makefile() to pickle: it works, because makefile() returns a BufferedReader/Writer which takes care of short read/write. But the documentation just says "file object". And if you have a look the file object definition in the glossary: https://docs.python.org/3.5/glossary.html#term-file-object """ There are actually three categories of file objects: raw binary files, buffered binary files and text files. Their interfaces are defined in the io module. The canonical way to create a file object is by using the open() function. """ So someone passing e.g. a raw binary file - which doesn't handle short reads/writes - would run into trouble. It's the same thing for e.g. GzipFile, and probably many others. Would it make sense to add a note somewhere? _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com