ConfigParser._interpolate(): Pass the missing key to the

InterpolationError constructor, not the KeyError exception itself.
    (Caught by the new InterpolationError test.)

SafeConfigParser._interpolate_some():  Pass the right number of
    arguments to the InterpolationError constructor.
    (Caught by pychecker.)
This commit is contained in:
Fred Drake 2002-12-31 06:55:41 +00:00
parent a3661e1267
commit 00dc5a93c1

View file

@ -554,8 +554,8 @@ class ConfigParser(RawConfigParser):
if value.find("%(") != -1: if value.find("%(") != -1:
try: try:
value = value % vars value = value % vars
except KeyError, key: except KeyError, e:
raise InterpolationError(key, option, section, rawval) raise InterpolationError(e[0], option, section, rawval)
else: else:
break break
if value.find("%(") != -1: if value.find("%(") != -1:
@ -599,8 +599,7 @@ class SafeConfigParser(ConfigParser):
try: try:
v = map[var] v = map[var]
except KeyError: except KeyError:
raise InterpolationError( raise InterpolationError(var, option, section, rest)
"no value found for %r" % var)
if "%" in v: if "%" in v:
self._interpolate_some(option, accum, v, self._interpolate_some(option, accum, v,
section, map, depth + 1) section, map, depth + 1)