Mercurial > cpython-lru_cache-weakref
diff Lib/ConfigParser.py @ 63910:4f76ce69aed0 2.7
Issue #9551: Do not raise TypeError when setting the value to None for
SafeConfigParser instances constructed with allow_no_value == True.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Tue, 10 Aug 2010 13:09:54 +0000 |
| parents | 473a8068f6c5 |
| children | 16cefdfed682 |
line wrap: on
line diff
--- a/Lib/ConfigParser.py Tue Aug 10 04:03:03 2010 +0000 +++ b/Lib/ConfigParser.py Tue Aug 10 13:09:54 2010 +0000 @@ -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)
