<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _generate_to_tempfile(self, generator):
 """Applies the specified generator to a temp file and returns the path to that file. We generate into a temp file so that we don't lose any manual customizations on error."""

    with temporary_file(cleanup=False, binary_mode=False) as output:
      generator.write(output)
      return output.name