From 4858770ee71f7cc63efae3bafeddf85c1150f1e6 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 21 Aug 2003 11:47:43 +0000 Subject: [PATCH] Ew, modified the original argument in utils.commaAndify. --- src/utils.py | 6 +++++- test/test_utils.py | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/utils.py b/src/utils.py index e98ad78bd..21cbe79ee 100755 --- a/src/utils.py +++ b/src/utils.py @@ -267,7 +267,11 @@ def commaAndify(L): elif len(L) == 2: return '%s and %s' % (L[0], L[1]) else: + # Not technically threadsafe. But we'll see if that matters. + originalLastElement = L[-1] L[-1] = 'and %s' % L[-1] - return ', '.join(L) + s = ', '.join(L) + L[-1] = originalLastElement + return s # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/test/test_utils.py b/test/test_utils.py index 474635f8b..27af93c59 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -134,11 +134,17 @@ class UtilsTest(unittest.TestCase): def testCommaAndify(self): L = ['foo'] + original = L[:] self.assertEqual(utils.commaAndify(L), 'foo') + self.assertEqual(L, original) L.append('bar') + original = L[:] self.assertEqual(utils.commaAndify(L), 'foo and bar') + self.assertEqual(L, original) L.append('baz') + original = L[:] self.assertEqual(utils.commaAndify(L), 'foo, bar, and baz') + self.assertEqual(L, original) # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: