def _openFile(self):
    """
    Fix Umask Issue https://twistedmatrix.com/trac/ticket/7026
    """
    openMode = self.defaultMode or 0777
    self._file = os.fdopen(os.open(
      self.path, os.O_CREAT|os.O_RDWR, openMode), 'r+', 1)
    self.closed = False
    # Try our best to update permissions for files which already exist.
    if self.defaultMode:
      try:
        os.chmod(self.path, self.defaultMode)
      except __HOLE__:
        pass
    # Seek is needed for uniformity of stream positioning
    # for read and write between Linux and BSD systems due
    # to differences in fopen() between operating systems.
    self._file.seek(0, os.SEEK_END)
    self.lastDate = self.toDate(os.stat(self.path)[8])
dataset/ETHPy150Open graphite-project/carbon/lib/carbon/log.py/CarbonLogFile._openFile