Merged revisions 68951 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r68951 | tarek.ziade | 2009-01-26 00:34:00 +0100 (Mon, 26 Jan 2009) | 1 line

  Fixed #1885: --formats=tar,gztar was not working properly in the sdist command
........
diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py
index 96fb7fa..054fe19 100644
--- a/Lib/distutils/command/sdist.py
+++ b/Lib/distutils/command/sdist.py
@@ -428,6 +428,10 @@
 
         self.make_release_tree(base_dir, self.filelist.files)
         archive_files = []              # remember names of files we create
+        # tar archive must be created last to avoid overwrite and remove
+        if 'tar' in self.formats:
+            self.formats.append(self.formats.pop(self.formats.index('tar')))
+
         for fmt in self.formats:
             file = self.make_archive(base_name, fmt, base_dir=base_dir)
             archive_files.append(file)