According to the docs, __name__ is not exposed via the API except
indirectly via %(__name__)s. Not sure why, but maintain the documented behavior for the new items() method. Be a little more efficient about how we compute the list of options in the ConfigParser.items() method.
This commit is contained in:
parent
97d5f05221
commit
df393bd46a
|
@ -274,8 +274,11 @@ class RawConfigParser:
|
||||||
except KeyError:
|
except KeyError:
|
||||||
if section != DEFAULTSECT:
|
if section != DEFAULTSECT:
|
||||||
raise NoSectionError(section)
|
raise NoSectionError(section)
|
||||||
|
d2 = {}
|
||||||
d = self._defaults.copy()
|
d = self._defaults.copy()
|
||||||
d.update(d2)
|
d.update(d2)
|
||||||
|
if "__name__" in d:
|
||||||
|
del d["__name__"]
|
||||||
return d.items()
|
return d.items()
|
||||||
|
|
||||||
def _get(self, section, conv, option):
|
def _get(self, section, conv, option):
|
||||||
|
@ -508,11 +511,14 @@ class ConfigParser(RawConfigParser):
|
||||||
# Update with the entry specific variables
|
# Update with the entry specific variables
|
||||||
if vars:
|
if vars:
|
||||||
d.update(vars)
|
d.update(vars)
|
||||||
|
options = d.keys()
|
||||||
|
if "__name__" in options:
|
||||||
|
options.remove("__name__")
|
||||||
if raw:
|
if raw:
|
||||||
for option in self.options(section):
|
for option in options:
|
||||||
yield (option, d[option])
|
yield (option, d[option])
|
||||||
else:
|
else:
|
||||||
for option in self.options(section):
|
for option in options:
|
||||||
yield (option,
|
yield (option,
|
||||||
self._interpolate(section, option, d[option], d))
|
self._interpolate(section, option, d[option], d))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue