mirror of https://github.com/python/cpython
gh-94196: Remove gzip.GzipFile.filename attribute (#94197)
gzip: Remove the filename attribute of gzip.GzipFile, deprecated since Python 2.6, use the name attribute instead. In write mode, the filename attribute added '.gz' file extension if it was not present.
This commit is contained in:
parent
d435a18c53
commit
d3a27e4c93
|
@ -165,6 +165,10 @@ The module defines the following items:
|
||||||
.. versionchanged:: 3.6
|
.. versionchanged:: 3.6
|
||||||
Accepts a :term:`path-like object`.
|
Accepts a :term:`path-like object`.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.12
|
||||||
|
Remove the ``filename`` attribute, use the :attr:`~GzipFile.name`
|
||||||
|
attribute instead.
|
||||||
|
|
||||||
.. deprecated:: 3.9
|
.. deprecated:: 3.9
|
||||||
Opening :class:`GzipFile` for writing without specifying the *mode*
|
Opening :class:`GzipFile` for writing without specifying the *mode*
|
||||||
argument is deprecated.
|
argument is deprecated.
|
||||||
|
|
|
@ -218,6 +218,12 @@ Removed
|
||||||
use :func:`os.urandom` or :func:`ssl.RAND_bytes` instead.
|
use :func:`os.urandom` or :func:`ssl.RAND_bytes` instead.
|
||||||
(Contributed by Victor Stinner in :gh:`94199`.)
|
(Contributed by Victor Stinner in :gh:`94199`.)
|
||||||
|
|
||||||
|
* :mod:`gzip`: Remove the ``filename`` attribute of :class:`gzip.GzipFile`,
|
||||||
|
deprecated since Python 2.6, use the :attr:`~gzip.GzipFile.name` attribute
|
||||||
|
instead. In write mode, the ``filename`` attribute added ``'.gz'`` file
|
||||||
|
extension if it was not present.
|
||||||
|
(Contributed by Victor Stinner in :gh:`94196`.)
|
||||||
|
|
||||||
|
|
||||||
Porting to Python 3.12
|
Porting to Python 3.12
|
||||||
======================
|
======================
|
||||||
|
|
|
@ -212,14 +212,6 @@ class GzipFile(_compression.BaseStream):
|
||||||
if self.mode == WRITE:
|
if self.mode == WRITE:
|
||||||
self._write_gzip_header(compresslevel)
|
self._write_gzip_header(compresslevel)
|
||||||
|
|
||||||
@property
|
|
||||||
def filename(self):
|
|
||||||
import warnings
|
|
||||||
warnings.warn("use the name attribute", DeprecationWarning, 2)
|
|
||||||
if self.mode == WRITE and self.name[-3:] != ".gz":
|
|
||||||
return self.name + ".gz"
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mtime(self):
|
def mtime(self):
|
||||||
"""Last modification time read from stream, or None"""
|
"""Last modification time read from stream, or None"""
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
:mod:`gzip`: Remove the ``filename`` attribute of :class:`gzip.GzipFile`,
|
||||||
|
deprecated since Python 2.6, use the :attr:`~gzip.GzipFile.name` attribute
|
||||||
|
instead. In write mode, the ``filename`` attribute added ``'.gz'`` file
|
||||||
|
extension if it was not present. Patch by Victor Stinner.
|
Loading…
Reference in New Issue