get(): Fixed a bug in the merge order of the dictionaries. This makes

a copy of the defaults dictionary and merges the section's dictionary
into it so that sections can override the defaults.
This commit is contained in:
Barry Warsaw 1998-01-26 22:42:48 +00:00
parent c6c921a4de
commit 5da0f504ba
1 changed files with 4 additions and 3 deletions

View File

@ -164,13 +164,14 @@ class ConfigParser:
The section DEFAULT is special. The section DEFAULT is special.
""" """
try: try:
d = self.__sections[section].copy() sectdict = self.__sections[section].copy()
except KeyError: except KeyError:
if section == DEFAULTSECT: if section == DEFAULTSECT:
d = {} sectdict = {}
else: else:
raise NoSectionError(section) raise NoSectionError(section)
d.update(self.__defaults) d = self.__defaults.copy()
d.update(sectdict)
option = string.lower(option) option = string.lower(option)
try: try:
rawval = d[option] rawval = d[option]