Index: Lib/ConfigParser.py =================================================================== --- Lib/ConfigParser.py (revision 83912) +++ Lib/ConfigParser.py (working copy) @@ -699,13 +699,13 @@ if self._optcre is self.OPTCRE or value: if not isinstance(value, basestring): raise TypeError("option values must be strings") - # check for bad percent signs: - # first, replace all "good" interpolations - tmp_value = value.replace('%%', '') - tmp_value = self._interpvar_re.sub('', tmp_value) - # then, check if there's a lone percent sign left - percent_index = tmp_value.find('%') - if percent_index != -1: - raise ValueError("invalid interpolation syntax in %r at " - "position %d" % (value, percent_index)) + if value is not None: + # check for bad percent signs: + # first, replace all "good" interpolations + tmp_value = value.replace('%%', '') + tmp_value = self._interpvar_re.sub('', tmp_value) + # then, check if there's a lone percent sign left + if '%' in tmp_value: + raise ValueError("invalid interpolation syntax in %r at " + "position %d" % (value, tmp_value.find('%'))) ConfigParser.set(self, section, option, value) Index: Lib/test/test_cfgparser.py =================================================================== --- Lib/test/test_cfgparser.py (revision 83912) +++ Lib/test/test_cfgparser.py (working copy) @@ -357,6 +357,7 @@ class ConfigParserTestCase(TestCaseBase): config_class = ConfigParser.ConfigParser + allow_no_value = True def test_interpolation(self): rawval = { @@ -397,6 +398,7 @@ cf.set('non-string', 'dict', {'pi': 3.14159, '%(': 1, '%(list)': '%(list)'}) cf.set('non-string', 'string_with_interpolation', '%(list)s') + cf.set('non-string', 'no-value') self.assertEqual(cf.get('non-string', 'int', raw=True), 1) self.assertRaises(TypeError, cf.get, 'non-string', 'int') self.assertEqual(cf.get('non-string', 'list', raw=True), @@ -409,6 +411,7 @@ raw=True), '%(list)s') self.assertRaises(ValueError, cf.get, 'non-string', 'string_with_interpolation', raw=False) + self.assertEqual(cf.get('non-string', 'no-value'), None) class MultilineValuesTestCase(TestCaseBase): config_class = ConfigParser.ConfigParser