mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
Patch #1603688: ConfigParser.SafeConfigParser now checks values that
are set for invalid interpolation sequences that would lead to errors on reading back those values.
This commit is contained in:
parent
a36cde4ccc
commit
92a6baed7b
3 changed files with 27 additions and 2 deletions
|
@ -422,6 +422,18 @@ class SafeConfigParserTestCase(ConfigParserTestCase):
|
|||
self.assertEqual(cf.get("section", "ok"), "xxx/%s")
|
||||
self.assertEqual(cf.get("section", "not_ok"), "xxx/xxx/%s")
|
||||
|
||||
def test_set_malformatted_interpolation(self):
|
||||
cf = self.fromstring("[sect]\n"
|
||||
"option1=foo\n")
|
||||
|
||||
self.assertEqual(cf.get('sect', "option1"), "foo")
|
||||
|
||||
self.assertRaises(ValueError, cf.set, "sect", "option1", "%foo")
|
||||
self.assertRaises(ValueError, cf.set, "sect", "option1", "foo%")
|
||||
self.assertRaises(ValueError, cf.set, "sect", "option1", "f%oo")
|
||||
|
||||
self.assertEqual(cf.get('sect', "option1"), "foo")
|
||||
|
||||
def test_set_nonstring_types(self):
|
||||
cf = self.fromstring("[sect]\n"
|
||||
"option1=foo\n")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue