mirror of https://github.com/python/cpython
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.
This commit is contained in:
parent
aabf404ecc
commit
727bd0b687
|
@ -140,6 +140,10 @@ Some facts and figures:
|
||||||
Constant for a :mod:`gzip` compressed tar archive.
|
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
|
.. exception:: TarError
|
||||||
|
|
||||||
Base class for all :mod:`tarfile` exceptions.
|
Base class for all :mod:`tarfile` exceptions.
|
||||||
|
|
|
@ -2468,6 +2468,9 @@ class TarFileCompat:
|
||||||
ZipFile class.
|
ZipFile class.
|
||||||
"""
|
"""
|
||||||
def __init__(self, file, mode="r", compression=TAR_PLAIN):
|
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:
|
if compression == TAR_PLAIN:
|
||||||
self.tarfile = TarFile.taropen(file, mode)
|
self.tarfile = TarFile.taropen(file, mode)
|
||||||
elif compression == TAR_GZIPPED:
|
elif compression == TAR_GZIPPED:
|
||||||
|
@ -2501,10 +2504,10 @@ class TarFileCompat:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
import calendar
|
import calendar
|
||||||
zinfo.name = zinfo.filename
|
tinfo = TarInfo(zinfo.filename)
|
||||||
zinfo.size = zinfo.file_size
|
tinfo.size = len(bytes)
|
||||||
zinfo.mtime = calendar.timegm(zinfo.date_time)
|
tinfo.mtime = calendar.timegm(zinfo.date_time)
|
||||||
self.tarfile.addfile(zinfo, StringIO(bytes))
|
self.tarfile.addfile(tinfo, StringIO(bytes))
|
||||||
def close(self):
|
def close(self):
|
||||||
self.tarfile.close()
|
self.tarfile.close()
|
||||||
#class TarFileCompat
|
#class TarFileCompat
|
||||||
|
|
|
@ -38,6 +38,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #3039: Fix tarfile.TarFileCompat.writestr() which always
|
||||||
|
raised an AttributeError.
|
||||||
|
|
||||||
- Issue #2523: Fix quadratic behaviour when read()ing a binary file without
|
- Issue #2523: Fix quadratic behaviour when read()ing a binary file without
|
||||||
asking for a specific length.
|
asking for a specific length.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue