[issue9124] Mailbox module should use binary I/O, not text I/O

R. David Murray report at bugs.python.org
Sat Jan 29 20:24:40 CET 2011


R. David Murray <rdmurray at bitdance.com> added the comment:

(I hope you meant I was working on a patch :)

Patch is done, but there is one remaining test failure that I'm not sure how to handle.  The test is test_add_text_file_warns.  The code checks to see if a file is a subclass of io.TextIOWrapper, and if so warns that this is deprecated, grabs the buffer attribute, and reads the file as binary.  This works fine, except that in testing it I used a temporary file.  On Linux that works great, but on Windows the temporary file is a tempfile._TemporaryFileWrapper, and that is *not* a subclass of io.TextIOWrapper.  So the code falls through to the "this must be a binary file" code and fails with a TypeError.

Any thoughts on how to handle this edge case?

I've got stuff to do this afternoon but I'll check back later to see if anybody has any ideas and, if all else fails, will disable that test on Windows.  It means the module doesn't handle temporary-text-file input on Windows correctly, but since we are deprecating text files anyway I think that is not a show stopper.

----------
Added file: http://bugs.python.org/file20608/mailbox5.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9124>
_______________________________________


More information about the Python-bugs-list mailing list