docs: def write(self, data):
          """
          Write ``data`` to the file.
  
          :type data: bytes
          :param data: the data to be written to the file
          :rtype: int
          :return: the number of bytes written
          """
          _complain_ifclosed(self.closed)
          if self.__encoding:
              self.f.write(data.encode(self.__encoding, self.__errors))
              return len(data)
          else:
              return self.f.write(data)