changeset 4049:49f330e9831a

tarfile: port fix from Python SVN rev 57617 TarFile.__init__() no longer fails if no name argument is passed and the fileobj argument has no usable name attribute (e.g. StringIO).
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 30 Aug 2008 18:09:28 +0200
parents eb9ee3746030
children 6f6eed3818ed f7e942210f52
files MoinMoin/support/tarfile.py
diffstat 1 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/support/tarfile.py	Sat Aug 30 16:40:29 2008 +0200
+++ b/MoinMoin/support/tarfile.py	Sat Aug 30 18:09:28 2008 +0200
@@ -1053,22 +1053,21 @@
            can be determined, `mode' is overridden by `fileobj's mode.
            `fileobj' is not closed, when TarFile is closed.
         """
-        self.name = os.path.abspath(name)
-
         if len(mode) > 1 or mode not in "raw":
             raise ValueError("mode must be 'r', 'a' or 'w'")
         self._mode = mode
         self.mode = {"r": "rb", "a": "r+b", "w": "wb"}[mode]
 
         if not fileobj:
-            fileobj = file(self.name, self.mode)
+            fileobj = file(name, self.mode)
             self._extfileobj = False
         else:
-            if self.name is None and hasattr(fileobj, "name"):
-                self.name = os.path.abspath(fileobj.name)
+            if name is None and hasattr(fileobj, "name"):
+                name = fileobj.name
             if hasattr(fileobj, "mode"):
                 self.mode = fileobj.mode
             self._extfileobj = True
+        self.name = name and os.path.abspath(name) or None
         self.fileobj = fileobj
 
         # Init datastructures