From: Philipp Gesang Date: Fri, 7 Apr 2017 14:59:19 +0000 (+0200) Subject: use OSError instead of IOError X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=26c899dcaae401cafb9498099cd8051bf4588ade;p=python-delta-tar use OSError instead of IOError IOError is a synonym for OSError, so the latter should be used everywhere to avoid confusion, especially when throwing the one but catching the other. Cf. PEP 3151. --- diff --git a/deltatar/tarfile.py b/deltatar/tarfile.py index 62b76f6..65513c5 100644 --- a/deltatar/tarfile.py +++ b/deltatar/tarfile.py @@ -876,7 +876,7 @@ class _Stream: if self.cmp is not None: try: buf = self.cmp.decompress(buf) - except IOError: + except OSError: raise ReadError("invalid compressed data") except Exception as e: # happens at the end of the file @@ -2859,7 +2859,7 @@ class TarFile(object): iterate = False try: copyfileobj(source, target, tarinfo.size) - except IOError: # on *any* IOError even in the target? + except OSError: source.close() # only if we are extracting a multivolume this can be treated if not self.new_volume_handler: diff --git a/testing/test_multivol.py b/testing/test_multivol.py index a7a4772..c99f521 100644 --- a/testing/test_multivol.py +++ b/testing/test_multivol.py @@ -731,7 +731,7 @@ class MultivolGnuFormatTest(BaseTest): try: tarobj.fileobj.close() tarobj.open_volume(volume_path) - except IOError as e: + except OSError as e: # only volume number 2 is missing assert volume_number == 2 raise e @@ -742,7 +742,7 @@ class MultivolGnuFormatTest(BaseTest): new_volume_handler=new_volume_handler2) try: tarobj.extractall() - except IOError as e: + except OSError as e: pass tarobj.close() assert os.path.exists("big")