Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-94196: Remove gzip.GzipFile.filename attribute#94197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
vstinner merged 1 commit intopython:mainfromvstinner:gzip_filename
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-94196: Remove gzip.GzipFile.filename attribute
gzip: Remove the filename attribute of gzip.GzipFile,deprecated since Python 2.6, use the name attribute instead. In writemode, the filename attribute added '.gz' file extension if it was notpresent.
  • Loading branch information
@vstinner
vstinner committedJun 24, 2022
commit254a83a99c0f89c6e0090392e4e6f9b071262c40
4 changes: 4 additions & 0 deletionsDoc/library/gzip.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,6 +165,10 @@ The module defines the following items:
.. versionchanged:: 3.6
Accepts a :term:`path-like object`.

.. versionchanged:: 3.12
Remove the ``filename`` attribute, use the :attr:`~GzipFile.name`
attribute instead.

.. deprecated:: 3.9
Opening :class:`GzipFile` for writing without specifying the *mode*
argument is deprecated.
Expand Down
6 changes: 6 additions & 0 deletionsDoc/whatsnew/3.12.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -218,6 +218,12 @@ Removed
use :func:`os.urandom` or :func:`ssl.RAND_bytes` instead.
(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
======================
Expand Down
8 changes: 0 additions & 8 deletionsLib/gzip.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -212,14 +212,6 @@ def __init__(self, filename=None, mode=None,
if self.mode == WRITE:
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
def mtime(self):
"""Last modification time read from stream, or None"""
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -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.

[8]ページ先頭

©2009-2025 Movatter.jp