diff --git a/sopel/config/types.py b/sopel/config/types.py index 58d8552a2d..5d9a463f06 100644 --- a/sopel/config/types.py +++ b/sopel/config/types.py @@ -273,7 +273,11 @@ def parse(self, value): multi-line string. """ if "\n" in value: - items = value.splitlines() + items = [ + # remove trailing comma + # because `value,\nother` is valid in Sopel 7.x + item.strip(self.DELIMITER).strip() + for item in value.splitlines()] else: # this behavior will be: # - Discouraged in Sopel 7.x (in the documentation) @@ -282,7 +286,7 @@ def parse(self, value): items = value.split(self.DELIMITER) value = list(filter(None, items)) - if self.strip: + if self.strip: # deprecate strip option in Sopel 8.x return [v.strip() for v in value] else: return value diff --git a/test/test_config.py b/test/test_config.py index c9a6e59552..34ade6820a 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -20,8 +20,8 @@ [spam] eggs = one, two, three, four, and a half bacons = grilled - burn out - greasy, fat, and tasty + burn out, + , greasy, fat, and tasty cheese = cheddar reblochon @@ -126,10 +126,10 @@ def test_listattribute_with_value_ending_in_special_chars(fakeconfig): assert fakeconfig.fake.listattr == ['spam', 'egg', 'sausage\\', 'bacon'] fakeconfig.fake.listattr = ['spam', 'egg', 'sausage,', 'bacon'] - assert fakeconfig.fake.listattr == ['spam', 'egg', 'sausage,', 'bacon'] + assert fakeconfig.fake.listattr == ['spam', 'egg', 'sausage', 'bacon'] fakeconfig.fake.listattr = ['spam', 'egg', 'sausage,,', 'bacon'] - assert fakeconfig.fake.listattr == ['spam', 'egg', 'sausage,,', 'bacon'] + assert fakeconfig.fake.listattr == ['spam', 'egg', 'sausage', 'bacon'] def test_listattribute_with_value_containing_adjacent_special_chars(fakeconfig):