Mercurial > cpython-lru_cache-weakref
diff Lib/ConfigParser.py @ 53108:a2492b4e505d legacy-trunk
#5741: dont disallow double percent signs in SafeConfigParser.set() keys.
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Sun, 12 Apr 2009 17:24:11 +0000 |
| parents | 6b1b2e7a06e9 |
| children | 1dc53e0a147a |
line wrap: on
line diff
--- a/Lib/ConfigParser.py Sun Apr 12 17:02:08 2009 +0000 +++ b/Lib/ConfigParser.py Sun Apr 12 17:24:11 2009 +0000 @@ -620,7 +620,6 @@ return ''.join(L) _interpvar_re = re.compile(r"%\(([^)]+)\)s") - _badpercent_re = re.compile(r"%[^%]|%$") def _interpolate_some(self, option, accum, rest, section, map, depth): if depth > MAX_INTERPOLATION_DEPTH: @@ -667,9 +666,10 @@ # check for bad percent signs: # first, replace all "good" interpolations tmp_value = self._interpvar_re.sub('', value) + tmp_value = tmp_value.replace('%%', '') # then, check if there's a lone percent sign left - m = self._badpercent_re.search(tmp_value) - if m: + percent_index = tmp_value.find('%') + if percent_index != -1: raise ValueError("invalid interpolation syntax in %r at " - "position %d" % (value, m.start())) + "position %d" % (value, percent_index)) ConfigParser.set(self, section, option, value)
