Replace IOError with OSError (#16715)
diff --git a/Lib/gzip.py b/Lib/gzip.py
index 998a8e5..698f0c2 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -287,10 +287,10 @@
             raise EOFError("Reached EOF")
 
         if magic != b'\037\213':
-            raise IOError('Not a gzipped file')
+            raise OSError('Not a gzipped file')
         method = ord( self.fileobj.read(1) )
         if method != 8:
-            raise IOError('Unknown compression method')
+            raise OSError('Unknown compression method')
         flag = ord( self.fileobj.read(1) )
         self.mtime = read32(self.fileobj)
         # extraflag = self.fileobj.read(1)
@@ -326,7 +326,7 @@
         self._check_closed()
         if self.mode != WRITE:
             import errno
-            raise IOError(errno.EBADF, "write() on read-only GzipFile object")
+            raise OSError(errno.EBADF, "write() on read-only GzipFile object")
 
         if self.fileobj is None:
             raise ValueError("write() on closed GzipFile object")
@@ -347,7 +347,7 @@
         self._check_closed()
         if self.mode != READ:
             import errno
-            raise IOError(errno.EBADF, "read() on write-only GzipFile object")
+            raise OSError(errno.EBADF, "read() on write-only GzipFile object")
 
         if self.extrasize <= 0 and self.fileobj is None:
             return b''
@@ -380,7 +380,7 @@
         self._check_closed()
         if self.mode != READ:
             import errno
-            raise IOError(errno.EBADF, "read1() on write-only GzipFile object")
+            raise OSError(errno.EBADF, "read1() on write-only GzipFile object")
 
         if self.extrasize <= 0 and self.fileobj is None:
             return b''
@@ -404,7 +404,7 @@
     def peek(self, n):
         if self.mode != READ:
             import errno
-            raise IOError(errno.EBADF, "peek() on write-only GzipFile object")
+            raise OSError(errno.EBADF, "peek() on write-only GzipFile object")
 
         # Do not return ridiculously small buffers, for one common idiom
         # is to call peek(1) and expect more bytes in return.
@@ -487,10 +487,10 @@
         crc32 = read32(self.fileobj)
         isize = read32(self.fileobj)  # may exceed 2GB
         if crc32 != self.crc:
-            raise IOError("CRC check failed %s != %s" % (hex(crc32),
+            raise OSError("CRC check failed %s != %s" % (hex(crc32),
                                                          hex(self.crc)))
         elif isize != (self.size & 0xffffffff):
-            raise IOError("Incorrect length of data produced")
+            raise OSError("Incorrect length of data produced")
 
         # Gzip files can be padded with zeroes and still have archives.
         # Consume all zero bytes and set the file position to the first
@@ -539,7 +539,7 @@
         '''Return the uncompressed stream file position indicator to the
         beginning of the file'''
         if self.mode != READ:
-            raise IOError("Can't rewind in write mode")
+            raise OSError("Can't rewind in write mode")
         self.fileobj.seek(0)
         self._new_member = True
         self.extrabuf = b""
@@ -564,7 +564,7 @@
                 raise ValueError('Seek from end not supported')
         if self.mode == WRITE:
             if offset < self.offset:
-                raise IOError('Negative seek in write mode')
+                raise OSError('Negative seek in write mode')
             count = offset - self.offset
             chunk = bytes(1024)
             for i in range(count // 1024):