diff options
author | David Goodger <goodger@python.org> | 2004-10-03 15:55:09 (GMT) |
---|---|---|
committer | David Goodger <goodger@python.org> | 2004-10-03 15:55:09 (GMT) |
commit | 1cbf206d322ad1fac12b4bb5a64d501ca021a61d (patch) | |
tree | 31ad42e2d25206665e9e3b381220967b358b87dd /Lib/ConfigParser.py | |
parent | 68a1abdadec2377fd3e8d2211cb3cc119de77a28 (diff) | |
download | cpython-1cbf206d322ad1fac12b4bb5a64d501ca021a61d.zip cpython-1cbf206d322ad1fac12b4bb5a64d501ca021a61d.tar.gz cpython-1cbf206d322ad1fac12b4bb5a64d501ca021a61d.tar.bz2 |
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.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/ConfigParser.py b/Lib/ConfigParser.py index acbf3ea..ade9614 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) |