mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-28286: Deprecate opening GzipFile for writing implicitly. (GH-16417)
Always specify the mode argument for writing.
This commit is contained in:
parent
bd44a7ead9
commit
a0652328a2
5 changed files with 25 additions and 2 deletions
|
@ -88,7 +88,8 @@ The module defines the following items:
|
|||
The *mode* argument can be any of ``'r'``, ``'rb'``, ``'a'``, ``'ab'``, ``'w'``,
|
||||
``'wb'``, ``'x'``, or ``'xb'``, depending on whether the file will be read or
|
||||
written. The default is the mode of *fileobj* if discernible; otherwise, the
|
||||
default is ``'rb'``.
|
||||
default is ``'rb'``. In future Python releases the mode of *fileobj* will
|
||||
not be used. It is better to always specify *mode* for writing.
|
||||
|
||||
Note that the file is always opened in binary mode. To open a compressed file
|
||||
in text mode, use :func:`.open` (or wrap your :class:`GzipFile` with an
|
||||
|
@ -164,6 +165,10 @@ The module defines the following items:
|
|||
.. versionchanged:: 3.6
|
||||
Accepts a :term:`path-like object`.
|
||||
|
||||
.. deprecated:: 3.9
|
||||
Opening :class:`GzipFile` for writing without specifying the *mode*
|
||||
argument is deprecated.
|
||||
|
||||
|
||||
.. function:: compress(data, compresslevel=9, *, mtime=None)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue