@@ -872,7 +872,7 @@ class TarInfo(object):
872
872
pax_headers = ('A dictionary containing key-value pairs of an '
873
873
'associated pax extended header.' ),
874
874
sparse = 'Sparse member information.' ,
875
- tarfile = None ,
875
+ _tarfile = None ,
876
876
_sparse_structs = None ,
877
877
_link_target = None ,
878
878
)
@@ -901,6 +901,24 @@ def __init__(self, name=""):
901
901
self .sparse = None # sparse member information
902
902
self .pax_headers = {} # pax header information
903
903
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
+
904
922
@property
905
923
def path (self ):
906
924
'In pax headers, "name" is called "path".'
@@ -2030,7 +2048,7 @@ def gettarinfo(self, name=None, arcname=None, fileobj=None):
2030
2048
# Now, fill the TarInfo object with
2031
2049
# information specific for the file.
2032
2050
tarinfo = self .tarinfo ()
2033
- tarinfo .tarfile = self # Not needed
2051
+ tarinfo ._tarfile = self # To be removed in 3.16.
2034
2052
2035
2053
# Use os.stat or os.lstat, depending on if symlinks shall be resolved.
2036
2054
if fileobj is None :
0 commit comments