Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue6759] zipfile.ZipExtFile.read() is missing universal newline support

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Apr 29, 2012, 2:41 AM

Post #1 of 5 (82 views)
Permalink
[issue6759] zipfile.ZipExtFile.read() is missing universal newline support

Serhiy Storchaka <storchaka [at] gmail> added the comment:

Support lines in zipfile looks contradictory and buggy. This complicates the code and makes the behavior of zipfile.ZipExtFile incompatible with the interface of other file-like objects. For example, the behavior of the read, read1 and peek differ from one described in io module.

If we are working with binary data, conversion of newlines is meaningless (and how about newlines in comments?). If we are working with text, the bytes must be decoded to str. This will help io.TextIOWrapper.

I suggest two alternatives:

1. Deprecate universal newline support in zipfile. zipfile.ZipExtFile should always work with non-modified bytes, and who need the text, let wraps zipfile.ZipExtFile with io.TextIOWrapper.

2. Automatically wrap a zipfile.ZipExtFile with io.TextIOWrapper if universal newlines mode is enabled. In this case, the data type will change from bytes to str. Add modes "t" and "b" to explicitly specify the data type. Add an encoding parameter (and other parameters if needed).

----------
nosy: +storchaka

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue6759>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Apr 29, 2012, 6:54 AM

Post #2 of 5 (78 views)
Permalink
[issue6759] zipfile.ZipExtFile.read() is missing universal newline support [In reply to]

Antoine Pitrou <pitrou [at] free> added the comment:

> Deprecate universal newline support in zipfile. zipfile.ZipExtFile
> should always work with non-modified bytes, and who need the text, let
> wraps zipfile.ZipExtFile with io.TextIOWrapper.

This would be fine with me.

----------
nosy: +pitrou
stage: patch review -> needs patch
type: behavior -> enhancement
versions: +Python 3.3 -Python 2.6, Python 2.7, Python 3.1, Python 3.2

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue6759>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Apr 29, 2012, 7:54 AM

Post #3 of 5 (74 views)
Permalink
[issue6759] zipfile.ZipExtFile.read() is missing universal newline support [In reply to]

Serhiy Storchaka <storchaka [at] gmail> added the comment:

> This would be fine with me.

It may be worth to deprecate PEP 278? Oh, only ten years have passed
since 2.3, but it seems it was so long ago.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue6759>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Apr 29, 2012, 8:05 AM

Post #4 of 5 (73 views)
Permalink
[issue6759] zipfile.ZipExtFile.read() is missing universal newline support [In reply to]

Antoine Pitrou <pitrou [at] free> added the comment:

> It may be worth to deprecate PEP 278? Oh, only ten years have passed
> since 2.3, but it seems it was so long ago.

Well, I don't know if PEPs ever get deprecated. In this case, PEP 3116
is probably the superseder.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue6759>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 1, 2012, 5:41 AM

Post #5 of 5 (74 views)
Permalink
[issue6759] zipfile.ZipExtFile.read() is missing universal newline support [In reply to]

Serhiy Storchaka <storchaka [at] gmail> added the comment:

I know how to remove universal newline support, I know how after this
correct these functions (with issue14371 they partially corrected), but
I don't know how to deprecate universal newline support. What should be
done? Can you initiate a discussion in Python-Ideas or Python-Dev? Now
only zipfile trying to implement this PEP (and failed), io ignores 'U'
mode, gzip checks and raises.

With regard to this issue, I note that there are tests that check that
read() returns unmodified data (UniversalNewlineTests.read_test in
Lib/test/test_zipfile.py). It looks weird, but apparently, this behavior
is expected and deliberate.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue6759>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.