]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
has_option(): Use the option name transform consistently.
authorFred Drake <fdrake@acm.org>
Thu, 26 Sep 2002 19:23:31 +0000 (19:23 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 26 Sep 2002 19:23:31 +0000 (19:23 +0000)
Closes SF bug #561822.

Lib/ConfigParser.py
Lib/test/test_cfgparser.py

index bdce25ef0d358189bf6539f6cc9985d96e4443a3..9b74a6380a953727de5865afbe59b3f1dbdd7257 100644 (file)
@@ -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
index 57e712579be74a10255b7ff5789e3c2ea1ddeee8..fbc915b7e47c2c37c31a66e2d99723693bcc1d10 100644 (file)
@@ -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..."