code: def _check(self, mode=None):
          
          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)
docs: Check if TarFile is still open, and if the operation's mode
             corresponds to TarFile's mode.