From 75b9da4aaf6b1636a116f4afd5b0d11a642c4401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Wed, 18 Aug 2004 13:57:44 +0000 Subject: Patch #995126: Correct directory size, and generate GNU tarfiles by default. --- Doc/lib/libtarfile.tex | 3 ++- Lib/tarfile.py | 4 ++-- Misc/NEWS | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Doc/lib/libtarfile.tex b/Doc/lib/libtarfile.tex index c841123..ce07c3e 100644 --- a/Doc/lib/libtarfile.tex +++ b/Doc/lib/libtarfile.tex @@ -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} diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 64d006d..ba5a1d2 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -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 diff --git a/Misc/NEWS b/Misc/NEWS index c6857dc..184c15c 100644 --- 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 -- cgit v0.12