From 7b2cb92b602a1fed0ee88f79f9e6d3c1c5037a3c Mon Sep 17 00:00:00 2001 From: InspectorCaracal Date: Mon, 26 Dec 2022 10:31:51 -0700 Subject: [PATCH] fix behavior with two items --- evennia/utils/tests/test_utils.py | 1 + evennia/utils/utils.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/evennia/utils/tests/test_utils.py b/evennia/utils/tests/test_utils.py index c7fe417ccb..cc245a5529 100644 --- a/evennia/utils/tests/test_utils.py +++ b/evennia/utils/tests/test_utils.py @@ -93,6 +93,7 @@ class TestListToString(TestCase): '"1", "2" and "3"', utils.list_to_string([1, 2, 3], endsep="and", addquote=True) ) self.assertEqual("1 and 2", utils.list_to_string([1, 2])) + self.assertEqual("1, 2", utils.list_to_string([1, 2], endsep=",")) class TestMLen(TestCase): diff --git a/evennia/utils/utils.py b/evennia/utils/utils.py index b96338dead..180f8e8b56 100644 --- a/evennia/utils/utils.py +++ b/evennia/utils/utils.py @@ -448,7 +448,7 @@ def iter_to_str(iterable, sep=",", endsep=", and", addquote=False): iterable = tuple(str(val) for val in iterable) if endsep: - if endsep.startswith(sep): + if endsep.startswith(sep) and endsep != sep: # oxford comma alternative endsep = endsep[1:] if len_iter < 3 else endsep elif endsep[0] not in punctuation: