[Python-checkins] cpython (3.2): Close #11548: Correctly handle format argument in shutil.unpack_archive

nick.coghlan python-checkins at python.org
Wed Mar 16 18:50:45 CET 2011


http://hg.python.org/cpython/rev/d1619747c17d
changeset:   68601:d1619747c17d
branch:      3.2
parent:      68598:382cb3386d57
user:        Nick Coghlan <ncoghlan at gmail.com>
date:        Wed Mar 16 13:52:20 2011 -0400
summary:
  Close #11548: Correctly handle format argument in shutil.unpack_archive

files:
  Lib/shutil.py
  Lib/test/test_shutil.py

diff --git a/Lib/shutil.py b/Lib/shutil.py
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -737,8 +737,8 @@
         except KeyError:
             raise ValueError("Unknown unpack format '{0}'".format(format))
 
-        func = format_info[0]
-        func(filename, extract_dir, **dict(format_info[1]))
+        func = format_info[1]
+        func(filename, extract_dir, **dict(format_info[2]))
     else:
         # we need to look at the registered unpackers supported extensions
         format = _find_unpack_format(filename)
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -645,6 +645,14 @@
             diff = self._compare_dirs(tmpdir, tmpdir2)
             self.assertEqual(diff, [])
 
+            # and again, this time with the format specified
+            tmpdir3 = self.mkdtemp()
+            unpack_archive(filename, tmpdir3, format=format)
+            diff = self._compare_dirs(tmpdir, tmpdir3)
+            self.assertEqual(diff, [])
+        self.assertRaises(shutil.ReadError, unpack_archive, TESTFN)
+        self.assertRaises(ValueError, unpack_archive, TESTFN, format='xxx')
+
     def test_unpack_registery(self):
 
         formats = get_unpack_formats()

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list