summaryrefslogtreecommitdiffstats
path: root/Lib/ConfigParser.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2002-10-25 20:41:30 (GMT)
committerFred Drake <fdrake@acm.org>2002-10-25 20:41:30 (GMT)
commitdf393bd46a0b98197a73407c55750519cd159a2e (patch)
tree0ffa4ce4d234d96359f426574c424ee53c0ea52e /Lib/ConfigParser.py
parent97d5f05221ab9a233883dadad56b91aa305cb860 (diff)
downloadcpython-df393bd46a0b98197a73407c55750519cd159a2e.zip
cpython-df393bd46a0b98197a73407c55750519cd159a2e.tar.gz
cpython-df393bd46a0b98197a73407c55750519cd159a2e.tar.bz2
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.
Diffstat (limited to 'Lib/ConfigParser.py')
-rw-r--r--Lib/ConfigParser.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/ConfigParser.py b/Lib/ConfigParser.py
index 5e796c8..c623ec9 100644
--- a/Lib/ConfigParser.py
+++ b/Lib/ConfigParser.py
@@ -274,8 +274,11 @@ class RawConfigParser:
except KeyError:
if section != DEFAULTSECT:
raise NoSectionError(section)
+ d2 = {}
d = self._defaults.copy()
d.update(d2)
+ if "__name__" in d:
+ del d["__name__"]
return d.items()
def _get(self, section, conv, option):
@@ -508,11 +511,14 @@ class ConfigParser(RawConfigParser):
# Update with the entry specific variables
if vars:
d.update(vars)
+ options = d.keys()
+ if "__name__" in options:
+ options.remove("__name__")
if raw:
- for option in self.options(section):
+ for option in options:
yield (option, d[option])
else:
- for option in self.options(section):
+ for option in options:
yield (option,
self._interpolate(section, option, d[option], d))