diff options
-rw-r--r-- | openstack/common/iniparser.py | 3 | ||||
-rw-r--r-- | tests/unit/test_iniparser.py | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/openstack/common/iniparser.py b/openstack/common/iniparser.py index e91eea5..2412844 100644 --- a/openstack/common/iniparser.py +++ b/openstack/common/iniparser.py @@ -53,7 +53,8 @@ class BaseParser(object): key, value = line[:colon], line[colon + 1:] value = value.strip() - if value[0] == value[-1] and value[0] == "\"" or value[0] == "'": + if ((value and value[0] == value[-1]) and + (value[0] == "\"" or value[0] == "'")): value = value[1:-1] return key.strip(), [value] diff --git a/tests/unit/test_iniparser.py b/tests/unit/test_iniparser.py index 30cae63..9e119e7 100644 --- a/tests/unit/test_iniparser.py +++ b/tests/unit/test_iniparser.py @@ -104,6 +104,11 @@ class ParserTestCase(unittest.TestCase): self.parser.parse(lines) self.assertTrue(self.parser.comment_called) + def test_empty_assignment(self): + lines = ["foo = "] + self.parser.parse(lines) + self.assertEquals(self.parser.values, {'': {'foo': ['']}}) + def test_assignment_space_single_quote(self): lines = ["foo = ' bar '"] self.parser.parse(lines) |