Fixed #31654 -- Fixed cache key validation messages.

This commit is contained in:
Mariusz Felisiak 2020-06-05 07:21:52 +02:00 committed by GitHub
parent f83b44075d
commit 926148ef01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 4 deletions

View File

@ -287,6 +287,6 @@ def memcache_key_warnings(key):
if ord(char) < 33 or ord(char) == 127:
yield (
'Cache key contains characters that will cause errors if '
'used with memcached: %r' % key, CacheKeyWarning
'used with memcached: %r' % key
)
break

13
docs/releases/2.2.14.txt Normal file
View File

@ -0,0 +1,13 @@
===========================
Django 2.2.14 release notes
===========================
*Expected July 1, 2020*
Django 2.2.14 fixes a bug in 2.2.13.
Bugfixes
========
* Fixed messages of ``InvalidCacheKey`` exceptions and ``CacheKeyWarning``
warnings raised by cache key validation (:ticket:`31654`).

View File

@ -9,4 +9,5 @@ Django 3.0.8 fixes several bugs in 3.0.7.
Bugfixes
========
* ...
* Fixed messages of ``InvalidCacheKey`` exceptions and ``CacheKeyWarning``
warnings raised by cache key validation (:ticket:`31654`).

View File

@ -54,6 +54,7 @@ versions of the documentation contain the release notes for any later releases.
.. toctree::
:maxdepth: 1
2.2.14
2.2.13
2.2.12
2.2.11

View File

@ -637,8 +637,9 @@ class BaseCacheTests:
cache.key_func = func
try:
with self.assertWarnsMessage(CacheKeyWarning, expected_warning):
with self.assertWarns(CacheKeyWarning) as cm:
cache.set(key, 'value')
self.assertEqual(str(cm.warning), expected_warning)
finally:
cache.key_func = old_func
@ -1276,8 +1277,9 @@ class BaseMemcachedTests(BaseCacheTests):
key.
"""
msg = expected_warning.replace(key, cache.make_key(key))
with self.assertRaisesMessage(InvalidCacheKey, msg):
with self.assertRaises(InvalidCacheKey) as cm:
cache.set(key, 'value')
self.assertEqual(str(cm.exception), msg)
def test_default_never_expiring_timeout(self):
# Regression test for #22845