mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-115256: Remove refcycles from tarfile writing (GH-115257)
This commit is contained in:
parent
cfbdce7208
commit
0dfa7ce346
3 changed files with 28 additions and 2 deletions
|
@ -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,
|
||||
)
|
||||
|
@ -901,6 +901,24 @@ class TarInfo(object):
|
|||
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".'
|
||||
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue