Kaydet (Commit) faffa158 authored tarafından Martin v. Löwis's avatar Martin v. Löwis

Revert previous checkin.

üst bc3b0608
...@@ -849,7 +849,7 @@ class TarFile(object): ...@@ -849,7 +849,7 @@ class TarFile(object):
can be determined, `mode' is overridden by `fileobj's mode. can be determined, `mode' is overridden by `fileobj's mode.
`fileobj' is not closed, when TarFile is closed. `fileobj' is not closed, when TarFile is closed.
""" """
self.name = os.path.abspath(name) self.name = name
if len(mode) > 1 or mode not in "raw": if len(mode) > 1 or mode not in "raw":
raise ValueError, "mode must be 'r', 'a' or 'w'" raise ValueError, "mode must be 'r', 'a' or 'w'"
...@@ -861,7 +861,7 @@ class TarFile(object): ...@@ -861,7 +861,7 @@ class TarFile(object):
self._extfileobj = False self._extfileobj = False
else: else:
if self.name is None and hasattr(fileobj, "name"): if self.name is None and hasattr(fileobj, "name"):
self.name = os.path.abspath(fileobj.name) self.name = fileobj.name
if hasattr(fileobj, "mode"): if hasattr(fileobj, "mode"):
self.mode = fileobj.mode self.mode = fileobj.mode
self._extfileobj = True self._extfileobj = True
...@@ -998,18 +998,22 @@ class TarFile(object): ...@@ -998,18 +998,22 @@ class TarFile(object):
raise CompressionError, "gzip module is not available" raise CompressionError, "gzip module is not available"
pre, ext = os.path.splitext(name) pre, ext = os.path.splitext(name)
pre = os.path.basename(pre)
if ext == ".tgz": if ext == ".tgz":
ext = ".tar" ext = ".tar"
if ext == ".gz": if ext == ".gz":
ext = "" ext = ""
tarname = os.path.basename(pre + ext) tarname = pre + ext
if fileobj is None: if fileobj is None:
fileobj = file(name, mode + "b") fileobj = file(name, mode + "b")
if mode != "r":
name = tarname
try: try:
t = cls.taropen(name, mode, t = cls.taropen(tarname, mode,
gzip.GzipFile(tarname, mode, compresslevel, fileobj) gzip.GzipFile(name, mode, compresslevel, fileobj)
) )
except IOError: except IOError:
raise ReadError, "not a gzip file" raise ReadError, "not a gzip file"
...@@ -1029,11 +1033,19 @@ class TarFile(object): ...@@ -1029,11 +1033,19 @@ class TarFile(object):
except ImportError: except ImportError:
raise CompressionError, "bz2 module is not available" raise CompressionError, "bz2 module is not available"
pre, ext = os.path.splitext(name)
pre = os.path.basename(pre)
if ext == ".tbz2":
ext = ".tar"
if ext == ".bz2":
ext = ""
tarname = pre + ext
if fileobj is not None: if fileobj is not None:
raise ValueError, "no support for external file objects" raise ValueError, "no support for external file objects"
try: try:
t = cls.taropen(name, mode, bz2.BZ2File(name, mode, compresslevel=compresslevel)) t = cls.taropen(tarname, mode, bz2.BZ2File(name, mode, compresslevel=compresslevel))
except IOError: except IOError:
raise ReadError, "not a bzip2 file" raise ReadError, "not a bzip2 file"
t._extfileobj = False t._extfileobj = False
...@@ -1238,7 +1250,8 @@ class TarFile(object): ...@@ -1238,7 +1250,8 @@ class TarFile(object):
arcname = name arcname = name
# Skip if somebody tries to archive the archive... # Skip if somebody tries to archive the archive...
if self.name is not None and os.path.samefile(name, self.name): if self.name is not None \
and os.path.abspath(name) == os.path.abspath(self.name):
self._dbg(2, "tarfile: Skipped %r" % name) self._dbg(2, "tarfile: Skipped %r" % name)
return return
......
...@@ -188,8 +188,6 @@ Extension Modules ...@@ -188,8 +188,6 @@ Extension Modules
Library Library
------- -------
- Patch #1262036: Make tarfile name absolute. Fixes #1257255.
- Patch #827386: Support absolute source paths in msvccompiler.py. - Patch #827386: Support absolute source paths in msvccompiler.py.
- Patch #1105730: Apply the new implementation of commonprefix in posixpath - Patch #1105730: Apply the new implementation of commonprefix in posixpath
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment