[Python-checkins] python/dist/src/Lib ConfigParser.py,1.67,1.68

goodger at users.sourceforge.net goodger at users.sourceforge.net
Sun Oct 3 17:55:11 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23768/Lib

Modified Files:
	ConfigParser.py 
Log Message:
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.

Index: ConfigParser.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/ConfigParser.py,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- ConfigParser.py	3 Oct 2004 15:40:24 -0000	1.67
+++ ConfigParser.py	3 Oct 2004 15:55:09 -0000	1.68
@@ -92,7 +92,8 @@
 __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 @@
 
     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 @@
                 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)



More information about the Python-checkins mailing list