summaryrefslogtreecommitdiff
path: root/Lib/ConfigParser.py
diff options
context:
space:
mode:
authorDavid Goodger <goodger@python.org>2004-10-03 15:55:09 +0000
committerDavid Goodger <goodger@python.org>2004-10-03 15:55:09 +0000
commitb484c61187076a2ad08832d5070a8cc69d041fd4 (patch)
tree46068f2f6ed49a194dcacf467cc294e5e428682a /Lib/ConfigParser.py
parent9a8ab2b26cea2cad81dfff9aed16c817df5bf54d (diff)
downloadcpython-b484c61187076a2ad08832d5070a8cc69d041fd4.tar.gz
SF bug #997050: Document, test, & check for non-string values in ConfigParser. Moved the new string-only restriction added in rev. 1.65 to the SafeConfigParser class, leaving existing ConfigParser & RawConfigParser behavior alone, and documented the conditions under which non-string values work.
Diffstat (limited to 'Lib/ConfigParser.py')
-rw-r--r--Lib/ConfigParser.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/ConfigParser.py b/Lib/ConfigParser.py
index acbf3ea144..ade9614796 100644
--- a/Lib/ConfigParser.py
+++ b/Lib/ConfigParser.py
@@ -92,7 +92,8 @@ import re
__all__ = ["NoSectionError", "DuplicateSectionError", "NoOptionError",
"InterpolationError", "InterpolationDepthError",
"InterpolationSyntaxError", "ParsingError",
- "MissingSectionHeaderError", "ConfigParser", "SafeConfigParser",
+ "MissingSectionHeaderError",
+ "ConfigParser", "SafeConfigParser", "RawConfigParser",
"DEFAULTSECT", "MAX_INTERPOLATION_DEPTH"]
DEFAULTSECT = "DEFAULT"
@@ -348,8 +349,6 @@ class RawConfigParser:
def set(self, section, option, value):
"""Set an option."""
- if not isinstance(value, basestring):
- raise TypeError("option values must be strings")
if not section or section == DEFAULTSECT:
sectdict = self._defaults
else:
@@ -633,3 +632,9 @@ class SafeConfigParser(ConfigParser):
raise InterpolationSyntaxError(
option, section,
"'%%' must be followed by '%%' or '(', found: %r" % (rest,))
+
+ def set(self, section, option, value):
+ """Set an option. Extend ConfigParser.set: check for string values."""
+ if not isinstance(value, basestring):
+ raise TypeError("option values must be strings")
+ ConfigParser.set(self, section, option, value)