'Get source filename.  If not saved, offer to save (or create) file
The debugger requires a source file.  Make sure there is one, and that
the current version of the source buffer has been saved.  If the user
declines to save or cancels the Save As dialog, return None.
If the user has configured IDLE for Autosave, the file will be
silently saved if it already exists and is dirty.'

def getfilename(self):

    filename = self.editwin.io.filename
    if (not self.editwin.get_saved()):
        autosave = idleConf.GetOption('main', 'General', 'autosave', type='bool')
        if (autosave and filename):
            self.editwin.io.save(None)
        else:
            confirm = self.ask_save_dialog()
            self.editwin.text.focus_set()
            if confirm:
                self.editwin.io.save(None)
                filename = self.editwin.io.filename
            else:
                filename = None
    return filename
