def _check(self, mode=None):
        """Check if TarFile is still open, and if the operation's mode
           corresponds to TarFile's mode.
        """
        if self.closed:
            raise IOError("%s is closed" % self.__class__.__name__)
        if mode is not None and self.mode not in mode:
            raise IOError("bad operation for mode %r" % self.mode)
Check if TarFile is still open, and if the operation's mode
           corresponds to TarFile's mode.
        
product/gradle-plugin/src/main/python/pip/_vendor/distlib/_backport/tarfile.py