This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: py3k: test_mailbox fails on Windows
Type: Stage:
Components: Windows Versions: Python 3.0
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, christian.heimes, paul.moore
Priority: normal Keywords: patch

Created on 2007-12-06 10:38 by amaury.forgeotdarc, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
mailbox.patch amaury.forgeotdarc, 2008-03-26 13:53
mailbox2.patch amaury.forgeotdarc, 2008-03-26 14:06
Messages (6)
msg58238 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2007-12-06 10:38
test_mailbox keeps failing on Windows, due to line-ending issues.
Difficult things began when the files started to open in text mode.

Trying to list problems:
- mailbox.py works with differences of tell() results, and uses this to
as an argument to read(). This is wrong for two reasons: tell() returns
an offset in the file, and mixes this with the codec status.
- _PartialFile (a narrowed view of a file) does not work, for the same
kinds of reasons.
msg58254 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2007-12-06 19:31
I believe that mailbox.py is expected to work with files opened in
binary mode. A long time ago I opened a bug on th email package
(http://bugs.python.org/issue586899) which turned out to be because
mailbox.py required binary mode files. The conclusion was that it
wouldn't be fixed (mainly because I couldn't work out a reasonable patch).

I could look again, but I doubt I'll be any better able to work out what
to do now...
msg58258 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2007-12-06 22:29
> mailbox.py is expected to work with files opened in binary mode
Not everywhere, unfortunately. Some files are still opened in text mode.
And this makes a huge difference with py3k: one accepts bytes, the other
requires strings.
msg64555 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-03-26 13:53
Three months later, one obvious correction: open all (text) files with
the newline='\n' option.

- This makes files identical between Unix and Windows version
- no more os.linesep

A compatibility problem: mailboxes created with python2.6 cannot be
opened with 3.0
msg64557 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-03-26 14:06
Another patch, which uses newline='' instead. Tests pass.
The patch is much smaller, and old files are more likely to be compatible.

OTOH, messages are unicode strings with \r\n.

Which one do you prefer?
msg64885 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-04-03 00:18
Applied 2nd solution as r61951
History
Date User Action Args
2022-04-11 14:56:28adminsetgithub: 45902
2008-04-03 00:18:42amaury.forgeotdarcsetstatus: open -> closed
resolution: fixed
messages: + msg64885
2008-03-26 14:06:19amaury.forgeotdarcsetfiles: + mailbox2.patch
messages: + msg64557
2008-03-26 13:53:13amaury.forgeotdarcsetfiles: + mailbox.patch
keywords: + patch
messages: + msg64555
2007-12-06 22:29:19amaury.forgeotdarcsetmessages: + msg58258
2007-12-06 19:31:24paul.mooresetnosy: + paul.moore
messages: + msg58254
2007-12-06 12:18:12christian.heimessetpriority: normal
nosy: + christian.heimes
2007-12-06 10:38:11amaury.forgeotdarccreate