From: Fred Drake Date: Thu, 26 Sep 2002 19:23:31 +0000 (+0000) Subject: has_option(): Use the option name transform consistently. X-Git-Tag: v2.2.2b1~98 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=37c0f6b91bd59fe1e82bd450827e3873fb9f8b15;p=thirdparty%2FPython%2Fcpython.git has_option(): Use the option name transform consistently. Closes SF bug #561822. --- diff --git a/Lib/ConfigParser.py b/Lib/ConfigParser.py index bdce25ef0d35..9b74a6380a95 100644 --- a/Lib/ConfigParser.py +++ b/Lib/ConfigParser.py @@ -320,6 +320,7 @@ class ConfigParser: def has_option(self, section, option): """Check for the existence of a given option in a given section.""" if not section or section == "DEFAULT": + option = self.optionxform(option) return self.__defaults.has_key(option) elif not self.has_section(section): return 0 diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py index 57e712579be7..fbc915b7e47c 100644 --- a/Lib/test/test_cfgparser.py +++ b/Lib/test/test_cfgparser.py @@ -97,6 +97,11 @@ def case_sensitivity(): verify(cf.options("MySection") == ["option"]) verify(cf.get("MySection", "Option") == "first line\nsecond line") + # SF bug #561822: + cf = ConfigParser.ConfigParser(defaults={"key":"value"}) + cf.readfp(StringIO.StringIO("[section]\nnekey=nevalue\n")) + verify(cf.has_option("section", "Key")) + def boolean(src): print "Testing interpretation of boolean Values..."