File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1851,6 +1851,7 @@ def __init__(self, tarfile):
18511851 """Construct a TarIter object.
18521852 """
18531853 self .tarfile = tarfile
1854+ self .index = 0
18541855 def __iter__ (self ):
18551856 """Return iterator object.
18561857 """
@@ -1859,10 +1860,20 @@ def next(self):
18591860 """Return the next item using TarFile's next() method.
18601861 When all members have been read, set TarFile as _loaded.
18611862 """
1862- tarinfo = self .tarfile .next ()
1863- if not tarinfo :
1864- self .tarfile ._loaded = True
1865- raise StopIteration
1863+ # Fix for SF #1100429: Under rare circumstances it can
1864+ # happen that getmembers() is called during iteration,
1865+ # which will cause TarIter to stop prematurely.
1866+ if not self .tarfile ._loaded :
1867+ tarinfo = self .tarfile .next ()
1868+ if not tarinfo :
1869+ self .tarfile ._loaded = True
1870+ raise StopIteration
1871+ else :
1872+ try :
1873+ tarinfo = self .tarfile .members [self .index ]
1874+ except IndexError :
1875+ raise StopIteration
1876+ self .index += 1
18661877 return tarinfo
18671878
18681879# Helper classes for sparse file support
Original file line number Diff line number Diff line change @@ -72,6 +72,9 @@ Extension Modules
7272Library
7373-------
7474
75+ - Patch #1103407: Properly deal with tarfile iterators when untarring
76+ symbolic links on Windows.
77+
7578- Patch #645894: Use getrusage for computing the time consumption in
7679 profile.py if available.
7780
You can’t perform that action at this time.
0 commit comments