code: def write(self, data):
      
      self._check_open()
      if not isinstance(data, str):
        raise TypeError('Expected str but got %s.' % type(data))
      if not data:
        return
      self._buffer.append(data)
      self._buffered += len(data)
      self._offset += len(data)
      if self._buffered >= self._flushsize:
        self._flush()
docs: Write some bytes.
  
      Args:
        data: data to write. str.
  
      Raises:
        TypeError: if data is not of type str.