diff options
author | Lars Gustäbel <lars@gustaebel.de> | 2008-08-02 11:26:39 (GMT) |
---|---|---|
committer | Lars Gustäbel <lars@gustaebel.de> | 2008-08-02 11:26:39 (GMT) |
commit | 727bd0b6874b32a42762251888cdfc2484286867 (patch) | |
tree | 3f055c4ab430b1454cbb34924fe0d51718e5b9d7 | |
parent | aabf404ecc06f1ddbb4c003508dff78c7ac06012 (diff) | |
download | cpython-727bd0b6874b32a42762251888cdfc2484286867.zip cpython-727bd0b6874b32a42762251888cdfc2484286867.tar.gz cpython-727bd0b6874b32a42762251888cdfc2484286867.tar.bz2 |
Issue #3039: Fix TarFileCompat.writestr() which always raised an
AttributeError since __slots__ were added to zipfile.ZipInfo in
r46967 two years ago.
Add a warning about the removal of TarFileCompat in Python 3.0.
-rw-r--r-- | Doc/library/tarfile.rst | 4 | ||||
-rw-r--r-- | Lib/tarfile.py | 11 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
3 files changed, 14 insertions, 4 deletions
diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst index b62148a..aabd641 100644 --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -140,6 +140,10 @@ Some facts and figures: Constant for a :mod:`gzip` compressed tar archive. + .. deprecated:: 2.6 + The :class:`TarFileCompat` class has been deprecated for removal in Python 3.0. + + .. exception:: TarError Base class for all :mod:`tarfile` exceptions. diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 6199213..85abcd8 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -2468,6 +2468,9 @@ class TarFileCompat: ZipFile class. """ def __init__(self, file, mode="r", compression=TAR_PLAIN): + from warnings import warnpy3k + warnpy3k("the TarFileCompat class has been removed in Python 3.0", + stacklevel=2) if compression == TAR_PLAIN: self.tarfile = TarFile.taropen(file, mode) elif compression == TAR_GZIPPED: @@ -2501,10 +2504,10 @@ class TarFileCompat: except ImportError: from StringIO import StringIO import calendar - zinfo.name = zinfo.filename - zinfo.size = zinfo.file_size - zinfo.mtime = calendar.timegm(zinfo.date_time) - self.tarfile.addfile(zinfo, StringIO(bytes)) + tinfo = TarInfo(zinfo.filename) + tinfo.size = len(bytes) + tinfo.mtime = calendar.timegm(zinfo.date_time) + self.tarfile.addfile(tinfo, StringIO(bytes)) def close(self): self.tarfile.close() #class TarFileCompat @@ -38,6 +38,9 @@ Core and Builtins Library ------- +- Issue #3039: Fix tarfile.TarFileCompat.writestr() which always + raised an AttributeError. + - Issue #2523: Fix quadratic behaviour when read()ing a binary file without asking for a specific length. |