https://github.com/python/cpython/commit/01088434512ced52d472a1857ae36e41c4e1e9c5
commit: 01088434512ced52d472a1857ae36e41c4e1e9c5
branch: main
author: sobolevn <[email protected]>
committer: encukou <[email protected]>
date: 2026-05-11T12:54:49+02:00
summary:
gh-149634: Remove deprecated and unused `tarfile.Tarfile.tarfile` attr
(GH-149635)
files:
A Misc/NEWS.d/next/Library/2026-05-10-14-10-00.gh-issue-149634.iT5cwC.rst
M Doc/whatsnew/3.16.rst
M Lib/tarfile.py
diff --git a/Doc/whatsnew/3.16.rst b/Doc/whatsnew/3.16.rst
index 967b3baf530a51..6d91d53f478d8e 100644
--- a/Doc/whatsnew/3.16.rst
+++ b/Doc/whatsnew/3.16.rst
@@ -140,6 +140,12 @@ sysconfig
which has been deprecated since Python 3.14.
Use the ``vars`` argument of :func:`sysconfig.get_paths` instead.
+tarfile
+-------
+
+* The undocumented and unused :attr:`!tarfile.TarFile.tarfile` attribute
+ has been deprecated since Python 3.13.
+
.. Add removals above alphabetically, not here at the end.
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 1394a26f2096ff..772b51295fcfbe 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -913,7 +913,6 @@ class TarInfo(object):
pax_headers = ('A dictionary containing key-value pairs of an '
'associated pax extended header.'),
sparse = 'Sparse member information.',
- _tarfile = None,
_sparse_structs = None,
_link_target = None,
)
@@ -942,24 +941,6 @@ def __init__(self, name=""):
self.sparse = None # sparse member information
self.pax_headers = {} # pax header information
- @property
- def tarfile(self):
- import warnings
- warnings.warn(
- 'The undocumented "tarfile" attribute of TarInfo objects '
- + 'is deprecated and will be removed in Python 3.16',
- DeprecationWarning, stacklevel=2)
- return self._tarfile
-
- @tarfile.setter
- def tarfile(self, tarfile):
- import warnings
- warnings.warn(
- 'The undocumented "tarfile" attribute of TarInfo objects '
- + 'is deprecated and will be removed in Python 3.16',
- DeprecationWarning, stacklevel=2)
- self._tarfile = tarfile
-
@property
def path(self):
'In pax headers, "name" is called "path".'
@@ -2196,7 +2177,6 @@ def gettarinfo(self, name=None, arcname=None,
fileobj=None):
# Now, fill the TarInfo object with
# information specific for the file.
tarinfo = self.tarinfo()
- tarinfo._tarfile = self # To be removed in 3.16.
# Use os.stat or os.lstat, depending on if symlinks shall be resolved.
if fileobj is None:
diff --git
a/Misc/NEWS.d/next/Library/2026-05-10-14-10-00.gh-issue-149634.iT5cwC.rst
b/Misc/NEWS.d/next/Library/2026-05-10-14-10-00.gh-issue-149634.iT5cwC.rst
new file mode 100644
index 00000000000000..620b66f754f5b5
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-05-10-14-10-00.gh-issue-149634.iT5cwC.rst
@@ -0,0 +1 @@
+Remove deprecated and unused :attr:`!tarfile.Tarfile.tarfile` attribute.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]