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.

Author ryles
Recipients ryles
Date 2009-08-22.06:22:00
SpamBayes Score 6.4582e-09
Marked as misclassified No
Message-id <>
The behavior with mode 'U' or 'rU' is not quite
as advertised in

Here is an example:

$ echo -ne "This is an example\r\nWhich demonstrates a problem\r\nwith, 'U')\r\n" > foo.txt
$ cat -v foo.txt
This is an example^M
Which demonstrates a problem^M
with, 'U')^M
$ zip foo.txt
  adding: foo.txt (deflated 1%)
$ python
Python 2.6.2 (r262:71600, Aug 21 2009, 17:52:12)
[GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> open("foo.txt", 'U').read()
"This is an example\nWhich demonstrates a problem\nwith, 'U')\n"
>>> from zipfile import ZipFile
>>> ZipFile("").open("foo.txt", 'U').read()
"This is an example\r\nWhich demonstrates a problem\r\nwith, 'U')\r\n"

The open() method was added here:

The cause is that the universal newline implementation is specific to
readline(), which also implements readlines() and next() as well.
Support was never added for read(), which is independent.

Note that test_zipfile.UniversalNewlineTests.readTest() passes. This is
suspect because it's explicitly coded to *not* expect translation of new
line sequences.
Date User Action Args
2009-08-22 06:22:02rylessetrecipients: + ryles
2009-08-22 06:22:02rylessetmessageid: <>
2009-08-22 06:22:01ryleslinkissue6759 messages
2009-08-22 06:22:00rylescreate