code: def _maketemp(name, createmode=None):
      
      d, fn = os.path.split(name)
      fd, tempname = tempfile.mkstemp(prefix=".%s-" % fn, dir=d)
      os.close(fd)
  
      # Temporary files are created with mode 0600, which is usually not
      # what we want. If the original file already exists, just copy its mode.
      # Otherwise, manually obey umask.
      try:
          st_mode = os.lstat(name).st_mode & 0o777
      except OSError as err:
          if err.errno != errno.ENOENT:
              raise
          st_mode = createmode
          if st_mode is None:
              st_mode = ~umask
          st_mode &= 0o666
      os.chmod(tempname, st_mode)
  
      return tempname
docs: Create a temporary file with the filename similar the given ``name``.
      The permission bits are copied from the original file or ``createmode``.
      Returns: the name of the temporary file.