diff options
author | Fred Drake <fdrake@acm.org> | 2001-07-06 17:23:22 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-07-06 17:23:22 (GMT) |
commit | f14452e15501e745d7e345586b6ad16a9abd0a22 (patch) | |
tree | 583bbdf38fd2b3ffd1b7c0fe9a63515c8f8eb4ec | |
parent | f891be9004dfc6ac8ffd8c862a785f2c7e5d1c14 (diff) | |
download | cpython-f14452e15501e745d7e345586b6ad16a9abd0a22.zip cpython-f14452e15501e745d7e345586b6ad16a9abd0a22.tar.gz cpython-f14452e15501e745d7e345586b6ad16a9abd0a22.tar.bz2 |
When reading a continuation line, make sure we still use the transformed
name when filling in the internal data structures, otherwise we incorrectly
raise a KeyError.
This fixes SF bug #432369.
-rw-r--r-- | Lib/ConfigParser.py | 3 | ||||
-rw-r--r-- | Lib/test/test_cfgparser.py | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/Lib/ConfigParser.py b/Lib/ConfigParser.py index cabbbdc..5eae972 100644 --- a/Lib/ConfigParser.py +++ b/Lib/ConfigParser.py @@ -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? diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py index 62395a0..0d8f199 100644 --- a/Lib/test/test_cfgparser.py +++ b/Lib/test/test_cfgparser.py @@ -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..." |