diff -r 1c51f1650c42 Lib/idlelib/configHandler.py --- a/Lib/idlelib/configHandler.py Fri Dec 26 23:08:58 2014 -0800 +++ b/Lib/idlelib/configHandler.py Sun Dec 28 13:32:20 2014 +0530 @@ -20,6 +20,7 @@ import os import sys +from collections import OrderedDict from configparser import ConfigParser @@ -67,6 +68,18 @@ "Load the configuration file from disk." self.read(self.file) + def write(self, fp, space_around_delimiters=True): + ''' + Sorts the sections in ascending lexicographic order before + writing to config file. See issue22706. + ''' + sorted_keys = sorted(list(self._sections)) + sorted_sections = OrderedDict() + for key in sorted_keys: + sorted_sections[key] = self._sections.get(key) + self._sections = sorted_sections + ConfigParser.write(self, fp, space_around_delimiters) + class IdleUserConfParser(IdleConfParser): """ IdleConfigParser specialised for user configuration handling.