summaryrefslogtreecommitdiffstats
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
authorpan324 <103143968+pan324@users.noreply.github.com>2024-03-04 13:26:32 (GMT)
committerGitHub <noreply@github.com>2024-03-04 13:26:32 (GMT)
commit0dfa7ce346ac003475aa45d25c76b13081b81217 (patch)
treeef41aba86421ea3f309cda71dbf471dd32ab3707 /Lib/tarfile.py
parentcfbdce72083fca791947cbb18114115c90738d99 (diff)
downloadcpython-0dfa7ce346ac003475aa45d25c76b13081b81217.zip
cpython-0dfa7ce346ac003475aa45d25c76b13081b81217.tar.gz
cpython-0dfa7ce346ac003475aa45d25c76b13081b81217.tar.bz2
gh-115256: Remove refcycles from tarfile writing (GH-115257)
Diffstat (limited to 'Lib/tarfile.py')
-rwxr-xr-xLib/tarfile.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index f4dd0fd..6f315a6 100755
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -872,7 +872,7 @@ class TarInfo(object):
pax_headers = ('A dictionary containing key-value pairs of an '
'associated pax extended header.'),
sparse = 'Sparse member information.',
- tarfile = None,
+ _tarfile = None,
_sparse_structs = None,
_link_target = None,
)
@@ -902,6 +902,24 @@ class TarInfo(object):
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".'
return self.name
@@ -2030,7 +2048,7 @@ class TarFile(object):
# Now, fill the TarInfo object with
# information specific for the file.
tarinfo = self.tarinfo()
- tarinfo.tarfile = self # Not needed
+ 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: