]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
When reading a continuation line, make sure we still use the transformed
authorFred Drake <fdrake@acm.org>
Fri, 6 Jul 2001 17:23:22 +0000 (17:23 +0000)
committerFred Drake <fdrake@acm.org>
Fri, 6 Jul 2001 17:23:22 +0000 (17:23 +0000)
name when filling in the internal data structures, otherwise we incorrectly
raise a KeyError.

This fixes SF bug #432369.

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

index cabbbdcf4f077e353332d0e511ad5d58dc3bc3a4..5eae972671698665c5ede90cb3136734d2ee0e38 100644 (file)
@@ -431,7 +431,8 @@ class ConfigParser:
             if line[0] in ' \t' and cursect is not None and optname:
                 value = line.strip()
                 if value:
-                    cursect[optname] = cursect[optname] + '\n ' + value
+                    k = self.optionxform(optname)
+                    cursect[k] = "%s\n%s" % (cursect[k], value)
             # a section header or option header?
             else:
                 # is it a section header?
index 62395a0c2fb943cc5ae9ad21025786aee396c60f..0d8f199a4ae212483570bc038b7f347ce3de72a1 100644 (file)
@@ -70,6 +70,13 @@ def case_sensitivity():
     cf.remove_option("a", "B")
     verify(cf.options("a") == [])
 
+    # SF bug #432369:
+    cf = ConfigParser.ConfigParser()
+    sio = StringIO.StringIO("[MySection]\nOption: first line\n\tsecond line\n")
+    cf.readfp(sio)
+    verify(cf.options("MySection") == ["option"])
+    verify(cf.get("MySection", "Option") == "first line\nsecond line")
+
 
 def interpolation(src):
     print "Testing value interpolation..."