'Load and update the recent files list and menus'

def update_recent_files_list(self, new_file=None):

    rf_list = []
    if os.path.exists(self.recent_files_path):
        with open(self.recent_files_path, 'r', encoding='utf_8', errors='replace') as rf_list_file:
            rf_list = rf_list_file.readlines()
    if new_file:
        new_file = (os.path.abspath(new_file) + '\n')
        if (new_file in rf_list):
            rf_list.remove(new_file)
        rf_list.insert(0, new_file)
    bad_paths = []
    for path in rf_list:
        if (('\x00' in path) or (not os.path.exists(path[0:(-1)]))):
            bad_paths.append(path)
    rf_list = [path for path in rf_list if (path not in bad_paths)]
    ulchars = '1234567890ABCDEFGHIJK'
    rf_list = rf_list[0:len(ulchars)]
    try:
        with open(self.recent_files_path, 'w', encoding='utf_8', errors='replace') as rf_file:
            rf_file.writelines(rf_list)
    except OSError as err:
        if (not getattr(self.root, 'recentfilelist_error_displayed', False)):
            self.root.recentfilelist_error_displayed = True
            tkMessageBox.showwarning(title='IDLE    Warning', message=('Cannot    update    File    menu    Recent    Files    list.    Your    operating    system    says:\n%s\nSelect    OK    and    IDLE    will    continue    without    updating.' % self._filename_to_unicode(str(err))), parent=self.text)
    for instance in self.top.instance_dict:
        menu = instance.recent_files_menu
        menu.delete(0, END)
        for (i, file_name) in enumerate(rf_list):
            file_name = file_name.rstrip()
            ufile_name = self._filename_to_unicode(file_name)
            callback = instance.__recent_file_callback(file_name)
            menu.add_command(label=((ulchars[i] + '    ') + ufile_name), command=callback, underline=0)
