diff options
author | Barry Warsaw <barry@python.org> | 1998-08-06 18:48:41 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 1998-08-06 18:48:41 (GMT) |
commit | 644621259344d24ff99644ad39ee6a841c5101cb (patch) | |
tree | 89e478db901a8ced508385fe72f2cd54da3e766f /Lib/ConfigParser.py | |
parent | f5475c95a767839b19f945eda16531427b47ca27 (diff) | |
download | cpython-644621259344d24ff99644ad39ee6a841c5101cb.zip cpython-644621259344d24ff99644ad39ee6a841c5101cb.tar.gz cpython-644621259344d24ff99644ad39ee6a841c5101cb.tar.bz2 |
Time machine experiment. Use '__name__' as the special key (always
present) that refers to the section name. Also added a (slightly)
better InterpolationError error message, which includes the raw
string.
Diffstat (limited to 'Lib/ConfigParser.py')
-rw-r--r-- | Lib/ConfigParser.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Lib/ConfigParser.py b/Lib/ConfigParser.py index f22306a..89e2d85 100644 --- a/Lib/ConfigParser.py +++ b/Lib/ConfigParser.py @@ -28,7 +28,7 @@ ConfigParser -- responsible for for parsing a list of dictionary of intrinsic defaults. The keys must be strings, the values must be appropriate for %()s string - interpolation. Note that `name' is + interpolation. Note that `__name__' is always an intrinsic default; it's value is the section's name. @@ -87,10 +87,14 @@ class NoOptionError(Error): self.section = section class InterpolationError(Error): - def __init__(self, reference, option, section): + def __init__(self, reference, option, section, rawval): Error.__init__(self, - "Bad value substitution: sect `%s', opt `%s', ref `%s'" - % (section, option, reference)) + "Bad value substitution:\n" + "\tsection: [%s]\n" + "\toption : %s\n" + "\tkey : %s\n" + "\trawval : %s\n" + % (section, option, reference, rawval)) self.reference = reference self.option = option self.section = section @@ -198,7 +202,7 @@ class ConfigParser: try: return rawval % d except KeyError, key: - raise InterpolationError(key, option, section) + raise InterpolationError(key, option, section, rawval) def __get(self, section, conv, option): return conv(self.get(section, option)) @@ -275,7 +279,7 @@ class ConfigParser: elif sectname == DEFAULTSECT: cursect = self.__defaults else: - cursect = {} + cursect = {'__name__': sectname} self.__sections[sectname] = cursect # So sections can't start with a continuation line optname = None |