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: Universal newline support for zipFile.ZipExtFile.read() is not working (deprecated?), and the missing functionality not documented
Type: behavior Stage: resolved
Components: Documentation Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: docs@python Nosy List: David Pitchford, docs@python, r.david.murray, serhiy.storchaka
Priority: normal Keywords:

Created on 2016-05-16 14:46 by David Pitchford, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
TestNewlines.zip David Pitchford, 2016-05-16 14:46 Archive containing the script to run and a test text file with irregular line endings
Messages (4)
msg265697 - (view) Author: David Pitchford (David Pitchford) Date: 2016-05-16 14:46
Universal newline support for the read method of ZipFileExt objects created by calling the ZipFile.open method is not working. The attached archive contains a test script for demonstrating the behavior; unzip the files into the same directory and run the script. It tests opening a text file with all three types of line endings in five different ways: with the file.read method in modes 'rU', 'r', and 'rb', and with the zipfile.ZipFileExt.read and readlines methods in mode 'rU'.

The first two and last methods both read the file with the expected universal newline support; the '\r' and '\r\n' endings are translated to '\n'. But zipfile.ZipFileExt.read, even with universal newline support, leaves these endings untouched, just like the 'rb' mode.

This issue seems to have been raised in the past (http://bugs.python.org/issue6759) for Python 3.3, with the decision apparently made to deprecate universal newline support for this method. Is this also the case for Python 2.7, and if so, why does the zipfile documentation for both versions not mention this missing functionality? As a user, I can say that this deprecation is certainly disrupting my workflow; it is not at all the behavior I expected.

I am running Python 2.7.11 on a 64-bit copy of Windows 7 Professional SP1.
msg265706 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-05-16 16:09
The decision was to deprecate 'U' *everywhere* in python3.

Yes, the 2.7 method you are concerned about is broken with respect to its documentation, which is what #6759 was about originally.  That issue was deemed too disruptive to the codebase to address effectively, but in fixing things properly for python3 we apparently lost track of the 2.7 bug.

You can fix the problem (in a forward compatible way) by wrapping the ZipExtFile in an io.TextIOWrapper.

The 2.7 documentation should be changed to address this issue and the solution.
msg265849 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-19 06:18
The support of the "U" mode will be removed in 3.6 (issue27029).
msg370444 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-05-31 13:24
Python 2.7 is no longer supported.
History
Date User Action Args
2022-04-11 14:58:31adminsetgithub: 71224
2020-05-31 13:24:02serhiy.storchakasetstatus: open -> closed
resolution: out of date
messages: + msg370444

stage: resolved
2016-05-19 06:18:55serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg265849
2016-05-16 16:09:22r.david.murraysetmessages: - msg265705
2016-05-16 16:09:14r.david.murraysetmessages: + msg265706
2016-05-16 16:08:24r.david.murraysetnosy: + docs@python, r.david.murray
messages: + msg265705

assignee: docs@python
components: + Documentation, - Library (Lib)
2016-05-16 14:46:53David Pitchfordcreate