From 37c0f6b91bd59fe1e82bd450827e3873fb9f8b15 Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Thu, 26 Sep 2002 19:23:31 +0000 Subject: has_option(): Use the option name transform consistently. Closes SF bug #561822. --- Lib/ConfigParser.py | 1 + Lib/test/test_cfgparser.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Lib/ConfigParser.py b/Lib/ConfigParser.py index bdce25e..9b74a63 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 57e7125..fbc915b 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..." -- cgit v0.12