[Python-checkins] cpython (3.5): Issue #27194: superfluous truncate calls in tarfile.py slow down extraction

lukasz.langa python-checkins at python.org
Sat Jun 11 19:59:29 EDT 2016


https://hg.python.org/cpython/rev/b63474aa8a5f
changeset:   101901:b63474aa8a5f
branch:      3.5
parent:      101893:f3c36afdedae
user:        Łukasz Langa <lukasz at langa.pl>
date:        Sat Jun 11 16:42:36 2016 -0700
summary:
  Issue #27194: superfluous truncate calls in tarfile.py slow down extraction

Patch by Jason Fried.

files:
  Lib/tarfile.py |  4 ++--
  Misc/ACKS      |  1 +
  2 files changed, 3 insertions(+), 2 deletions(-)


diff --git a/Lib/tarfile.py b/Lib/tarfile.py
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -2150,10 +2150,10 @@
                 for offset, size in tarinfo.sparse:
                     target.seek(offset)
                     copyfileobj(source, target, size, ReadError)
+                target.seek(tarinfo.size)
+                target.truncate()
             else:
                 copyfileobj(source, target, tarinfo.size, ReadError)
-            target.seek(tarinfo.size)
-            target.truncate()
 
     def makeunknown(self, tarinfo, targetpath):
         """Make a file from a TarInfo object with an unknown type
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -458,6 +458,7 @@
 Martin Franklin
 Kent Frazier
 Bruce Frederiksen
+Jason Fried
 Robin Friedrich
 Bradley Froehle
 Ivan Frohne

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list