From: Guido van Rossum Date: Thu, 17 Jun 1999 18:41:42 +0000 (+0000) Subject: Patch suggested (and partially provided) by Lars Damerow: instead of X-Git-Tag: v1.6a1~1199 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9e480adf9b3520ea3deb322fd1214f53a2293a0d;p=thirdparty%2FPython%2Fcpython.git Patch suggested (and partially provided) by Lars Damerow: instead of always lowercasing the option name, call a method optionxform() which can be overridden. Also make the regexps SECTRE and OPTRE non-private variables so they can also be overridden. --- diff --git a/Lib/ConfigParser.py b/Lib/ConfigParser.py index dd8b6d866726..4dbe606b0335 100644 --- a/Lib/ConfigParser.py +++ b/Lib/ConfigParser.py @@ -199,7 +199,7 @@ class ConfigParser: # Update with the entry specific variables if vars: d.update(vars) - option = string.lower(option) + option = self.optionxform(option) try: rawval = d[option] except KeyError: @@ -236,16 +236,19 @@ class ConfigParser: raise ValueError, 'Not a boolean: %s' % v return val + def optionxform(self, optionstr): + return string.lower(optionstr) + # # Regular expressions for parsing section headers and options. Note a # slight semantic change from the previous version, because of the use # of \w, _ is allowed in section header names. - __SECTCRE = re.compile( + SECTCRE = re.compile( r'\[' # [ r'(?P
[-\w]+)' # `-', `_' or any alphanum r'\]' # ] ) - __OPTCRE = re.compile( + OPTCRE = re.compile( r'(?P