diff options
author | Fred Drake <fdrake@acm.org> | 2010-08-10 13:09:54 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2010-08-10 13:09:54 (GMT) |
commit | 0a1fa0e8b1fc888ae9978003c836e5a1953daef5 (patch) | |
tree | b0441f342d177dea92c26fd8724e0b64ca8a2a28 /Lib/ConfigParser.py | |
parent | 2d930804ffdb2f279c7306532dba09de972cf885 (diff) | |
download | cpython-0a1fa0e8b1fc888ae9978003c836e5a1953daef5.zip cpython-0a1fa0e8b1fc888ae9978003c836e5a1953daef5.tar.gz cpython-0a1fa0e8b1fc888ae9978003c836e5a1953daef5.tar.bz2 |
Issue #9551: Do not raise TypeError when setting the value to None for
SafeConfigParser instances constructed with allow_no_value == True.
Diffstat (limited to 'Lib/ConfigParser.py')
-rw-r--r-- | Lib/ConfigParser.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/ConfigParser.py b/Lib/ConfigParser.py index 3e2175f..d356a13 100644 --- a/Lib/ConfigParser.py +++ b/Lib/ConfigParser.py @@ -699,13 +699,13 @@ class SafeConfigParser(ConfigParser): 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) |