mirror of
https://github.com/python/cpython.git
synced 2025-10-26 16:27:06 +00:00
Issue #27029: Removed deprecated support of universal newlines mode from ZipFile.open().
This commit is contained in:
parent
e6dae877dc
commit
e670be2273
5 changed files with 24 additions and 222 deletions
|
|
@ -204,18 +204,13 @@ ZipFile Objects
|
|||
Return a list of archive members by name.
|
||||
|
||||
|
||||
.. index::
|
||||
single: universal newlines; zipfile.ZipFile.open method
|
||||
|
||||
.. method:: ZipFile.open(name, mode='r', pwd=None, *, force_zip64=False)
|
||||
|
||||
Access a member of the archive as a file-like object. *name*
|
||||
is the name of the file in the archive, or a :class:`ZipInfo` object. The
|
||||
*mode* parameter, if included, must be one of the following: ``'r'`` (the
|
||||
default), ``'U'``, ``'rU'`` or ``'w'``. Choosing ``'U'`` or ``'rU'`` will
|
||||
enable :term:`universal newlines` support in the read-only object. *pwd* is
|
||||
the password used to decrypt encrypted ZIP files. Calling :meth:`.open` on
|
||||
a closed ZipFile will raise a :exc:`RuntimeError`.
|
||||
Access a member of the archive as a binary file-like object. *name*
|
||||
can be either the name of a file within the archive or a :class:`ZipInfo`
|
||||
object. The *mode* parameter, if included, must be ``'r'`` (the default)
|
||||
or ``'w'``. *pwd* is the password used to decrypt encrypted ZIP files.
|
||||
Calling :meth:`.open` on a closed ZipFile will raise a :exc:`RuntimeError`.
|
||||
|
||||
:meth:`~ZipFile.open` is also a context manager and therefore supports the
|
||||
:keyword:`with` statement::
|
||||
|
|
@ -224,7 +219,7 @@ ZipFile Objects
|
|||
with myzip.open('eggs.txt') as myfile:
|
||||
print(myfile.read())
|
||||
|
||||
With *mode* ``'r'``, ``'U'`` or ``'rU'``, the file-like object
|
||||
With *mode* ``'r'`` the file-like object
|
||||
(``ZipExtFile``) is read-only and provides the following methods:
|
||||
:meth:`~io.BufferedIOBase.read`, :meth:`~io.IOBase.readline`,
|
||||
:meth:`~io.IOBase.readlines`, :meth:`__iter__`,
|
||||
|
|
@ -248,8 +243,8 @@ ZipFile Objects
|
|||
or a :class:`ZipInfo` object. You will appreciate this when trying to read a
|
||||
ZIP file that contains members with duplicate names.
|
||||
|
||||
.. deprecated-removed:: 3.4 3.6
|
||||
The ``'U'`` or ``'rU'`` mode. Use :class:`io.TextIOWrapper` for reading
|
||||
.. versionchanged:: 3.6
|
||||
Removed support of ``mode='U'``. Use :class:`io.TextIOWrapper` for reading
|
||||
compressed text files in :term:`universal newlines` mode.
|
||||
|
||||
.. versionchanged:: 3.6
|
||||
|
|
|
|||
|
|
@ -580,6 +580,11 @@ API and Feature Removals
|
|||
:mod:`tkinter` widget classes were removed (corresponding Tk commands
|
||||
were obsolete since Tk 4.0).
|
||||
|
||||
* The :meth:`~zipfile.ZipFile.open` method of the :class:`zipfile.ZipFile`
|
||||
class no longer supports the ``'U'`` mode (was deprecated since Python 3.4).
|
||||
Use :class:`io.TextIOWrapper` for reading compressed text files in
|
||||
:term:`universal newlines` mode.
|
||||
|
||||
|
||||
Porting to Python 3.6
|
||||
=====================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue