Index: Lib/ConfigParser.py =================================================================== --- Lib/ConfigParser.py (revision 59894) +++ Lib/ConfigParser.py (working copy) @@ -235,8 +235,12 @@ """Create a new section in the configuration. Raise DuplicateSectionError if a section by the specified name - already exists. + already exists. Raise ValueError if name is DEFAULT or any of it's + case-insensitive variants. """ + if section.lower() == "default": + raise ValueError, 'Invalid section name: %s' % section + if section in self._sections: raise DuplicateSectionError(section) self._sections[section] = self._dict() Index: Lib/test/test_cfgparser.py =================================================================== --- Lib/test/test_cfgparser.py (revision 59894) +++ Lib/test/test_cfgparser.py (working copy) @@ -446,6 +446,14 @@ self.assertRaises(TypeError, cf.set, "sect", "option2", 1.0) self.assertRaises(TypeError, cf.set, "sect", "option2", object()) + def test_add_section_default_1(self): + cf = self.newconfig() + self.assertRaises(ValueError, cf.add_section, "default") + + def test_add_section_default_2(self): + cf = self.newconfig() + self.assertRaises(ValueError, cf.add_section, "DEFAULT") + class SortedTestCase(RawConfigParserTestCase): def newconfig(self, defaults=None): self.cf = self.config_class(defaults=defaults, dict_type=SortedDict) Index: Doc/library/configparser.rst =================================================================== --- Doc/library/configparser.rst (revision 59894) +++ Doc/library/configparser.rst (working copy) @@ -187,9 +187,10 @@ .. method:: RawConfigParser.add_section(section) Add a section named *section* to the instance. If a section by the given name - already exists, :exc:`DuplicateSectionError` is raised. + already exists, :exc:`DuplicateSectionError` is raised. If the name + ``DEFAULT`` (or any of it's case-insensitive variants) is passed, + :exc:`ValueError` is raised. - .. method:: RawConfigParser.has_section(section) Indicates whether the named section is present in the configuration. The