From d356bb653f4d90ae9809e5a051791ded39010c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Suliga?= Date: Mon, 4 Apr 2016 21:20:55 +0200 Subject: [PATCH] Fixed #26460 -- Issued a single warning for invalid cache key --- django/core/cache/backends/base.py | 1 + tests/cache/tests.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/django/core/cache/backends/base.py b/django/core/cache/backends/base.py index 12351c5bcd..0b13a881bf 100644 --- a/django/core/cache/backends/base.py +++ b/django/core/cache/backends/base.py @@ -242,6 +242,7 @@ class BaseCache(object): warnings.warn('Cache key contains characters that will cause ' 'errors if used with memcached: %r' % key, CacheKeyWarning) + break def incr_version(self, key, delta=1, version=None): """Adds delta to the cache version for the supplied key. Returns the diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 4a3d4bb128..ee27d71563 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -586,7 +586,7 @@ class BaseCacheTests(object): warnings.simplefilter("always") # memcached does not allow whitespace or control characters in keys cache.set('key with spaces', 'value') - self.assertEqual(len(w), 2) + self.assertEqual(len(w), 1) self.assertIsInstance(w[0].message, CacheKeyWarning) with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always")