]> granicus.if.org Git - python/commitdiff
Patch #995126: Correct directory size, and generate GNU tarfiles by default.
authorMartin v. Löwis <martin@v.loewis.de>
Wed, 18 Aug 2004 13:57:44 +0000 (13:57 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Wed, 18 Aug 2004 13:57:44 +0000 (13:57 +0000)
Doc/lib/libtarfile.tex
Lib/tarfile.py
Misc/NEWS

index c84112340df847aab4be73fc0b053cbfe6bce498..ce07c3ebd47d3f5a7d984dd2592a1ed6fa2f6817 100644 (file)
@@ -261,7 +261,8 @@ tar archive several times. Each archive member is represented by a
     gigabytes. A \exception{ValueError} is raised if a file exceeds
     this limit.  If false, create a GNU tar compatible archive.  It
     will not be \POSIX{} compliant, but can store files without any
-    of the above restrictions.
+    of the above restrictions. 
+    \versionchanged[\var{posix} defaults to false.]{2.4}
 \end{memberdesc}
 
 \begin{memberdesc}{dereference}
index 64d006deab4231d12804a14b529fe21375869cda..ba5a1d21f6fec0b9be0f1a0adaba26f741046428 100644 (file)
@@ -781,7 +781,7 @@ class TarFile(object):
                                 # messages (if debug >= 0). If > 0, errors
                                 # are passed to the caller as exceptions.
 
-    posix = True                # If True, generates POSIX.1-1990-compliant
+    posix = False               # If True, generates POSIX.1-1990-compliant
                                 # archives (no GNU extensions!)
 
     fileobject = ExFileObject
@@ -1137,7 +1137,7 @@ class TarFile(object):
         tarinfo.mode  = stmd
         tarinfo.uid   = statres.st_uid
         tarinfo.gid   = statres.st_gid
-        tarinfo.size  = statres.st_size
+        tarinfo.size  = not stat.S_ISDIR(stmd) and statres.st_size or 0
         tarinfo.mtime = statres.st_mtime
         tarinfo.type  = type
         tarinfo.linkname = linkname
index c6857dc9dd83b458bff012c757ed389d638a9069..184c15cecde4507363b44fc29d02a3fe524fec6e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -44,6 +44,8 @@ Extension modules
 Library
 -------
 
+- tarfile now generates GNU tar files by default.
+
 - HTTPResponse has now a getheaders method.
 
 - Patch #1006219: let inspect.getsource handle '@' decorators. Thanks Simon