@@ -872,7 +872,7 @@ class TarInfo(object):
872872 pax_headers = ('A dictionary containing key-value pairs of an '
873873 'associated pax extended header.' ),
874874 sparse = 'Sparse member information.' ,
875- tarfile = None ,
875+ _tarfile = None ,
876876 _sparse_structs = None ,
877877 _link_target = None ,
878878 )
@@ -901,6 +901,24 @@ def __init__(self, name=""):
901901 self .sparse = None # sparse member information
902902 self .pax_headers = {} # pax header information
903903
904+ @property
905+ def tarfile (self ):
906+ import warnings
907+ warnings .warn (
908+ 'The undocumented "tarfile" attribute of TarInfo objects '
909+ + 'is deprecated and will be removed in Python 3.16' ,
910+ DeprecationWarning , stacklevel = 2 )
911+ return self ._tarfile
912+
913+ @tarfile .setter
914+ def tarfile (self , tarfile ):
915+ import warnings
916+ warnings .warn (
917+ 'The undocumented "tarfile" attribute of TarInfo objects '
918+ + 'is deprecated and will be removed in Python 3.16' ,
919+ DeprecationWarning , stacklevel = 2 )
920+ self ._tarfile = tarfile
921+
904922 @property
905923 def path (self ):
906924 'In pax headers, "name" is called "path".'
@@ -2030,7 +2048,7 @@ def gettarinfo(self, name=None, arcname=None, fileobj=None):
20302048 # Now, fill the TarInfo object with
20312049 # information specific for the file.
20322050 tarinfo = self .tarinfo ()
2033- tarinfo .tarfile = self # Not needed
2051+ tarinfo ._tarfile = self # To be removed in 3.16.
20342052
20352053 # Use os.stat or os.lstat, depending on if symlinks shall be resolved.
20362054 if fileobj is None :
0 commit comments