[issue14061] Clean up archiving code in shutil

Éric Araujo report at bugs.python.org
Fri Feb 24 08:48:13 CET 2012


Éric Araujo <merwok at netwok.org> added the comment:

I intend to commit this simple fix for all branches:

-    _UNPACK_FORMATS['bztar'] = (['.bz2'], _unpack_tarfile, [],
+    _UNPACK_FORMATS['bztar'] = (['.tar.bz2'], _unpack_tarfile, [],

I could write a unit test, but it would be coupled to the exact text of the exception* (i.e. with assertRaisesRegex) and IMO not very useful.  I tested manually: I compressed a text file with bzip2, passed the filename to unpack_archive, and it tried to unpack it with tarfile.  With my fix, it does not try to unpack it.


* unpack_archive raises ValueError when you give an unsupported value to its format
  parameter, but when it’s in autodetect mode and can’t find an unpacker for the file
  extension, then it raises a ReadError.  Is it okay to change that to ValueError?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14061>
_______________________________________


More information about the Python-bugs-list mailing list