diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-12-25 14:47:37 (GMT) |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-12-25 14:47:37 (GMT) |
commit | f7a17b48d748e1835bcf9df86fb7fb318bb020f8 (patch) | |
tree | 403d91c57f72d6e538ce09a8037bd658bc619760 /Lib/zipfile.py | |
parent | 16bdd4120d8452e8e04b124bcdd116608c5166b0 (diff) | |
download | cpython-f7a17b48d748e1835bcf9df86fb7fb318bb020f8.zip cpython-f7a17b48d748e1835bcf9df86fb7fb318bb020f8.tar.gz cpython-f7a17b48d748e1835bcf9df86fb7fb318bb020f8.tar.bz2 |
Replace IOError with OSError (#16715)
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r-- | Lib/zipfile.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py index df4ed91..a2791cd 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -164,7 +164,7 @@ def _check_zipfile(fp): try: if _EndRecData(fp): return True # file has correct magic number - except IOError: + except OSError: pass return False @@ -180,7 +180,7 @@ def is_zipfile(filename): else: with open(filename, "rb") as fp: result = _check_zipfile(fp) - except IOError: + except OSError: pass return result @@ -190,7 +190,7 @@ def _EndRecData64(fpin, offset, endrec): """ try: fpin.seek(offset - sizeEndCentDir64Locator, 2) - except IOError: + except OSError: # If the seek fails, the file is not large enough to contain a ZIP64 # end-of-archive record, so just return the end record we were given. return endrec @@ -238,7 +238,7 @@ def _EndRecData(fpin): # file if this is the case). try: fpin.seek(-sizeEndCentDir, 2) - except IOError: + except OSError: return None data = fpin.read() if data[0:4] == stringEndArchive and data[-2:] == b"\000\000": @@ -895,7 +895,7 @@ class ZipFile: modeDict = {'r' : 'rb', 'w': 'wb', 'a' : 'r+b'} try: self.fp = io.open(file, modeDict[mode]) - except IOError: + except OSError: if mode == 'a': mode = key = 'w' self.fp = io.open(file, modeDict[mode]) @@ -946,7 +946,7 @@ class ZipFile: fp = self.fp try: endrec = _EndRecData(fp) - except IOError: + except OSError: raise BadZipFile("File is not a zip file") if not endrec: raise BadZipFile("File is not a zip file") |