Ticket #13686: add-unicode.patch

File add-unicode.patch, 1.2 KB (added by dmedvinsky, 4 years ago)

Reattached patch from duplicate ticket by jbalogh

  • django/core/cache/backends/memcached.py

    diff --git a/django/core/cache/backends/memcached.py b/django/core/cache/backends/memcached.py
    index 7d6b5b3..1de7dae 100644
    a b class CacheClass(BaseCache): 
    4040        return timeout
    4141
    4242    def add(self, key, value, timeout=0):
    43         if isinstance(value, unicode):
    44             value = value.encode('utf-8')
    4543        return self._cache.add(smart_str(key), value, self._get_memcache_timeout(timeout))
    4644
    4745    def get(self, key, default=None):
  • tests/regressiontests/cache/tests.py

    diff --git a/tests/regressiontests/cache/tests.py b/tests/regressiontests/cache/tests.py
    index 109374c..ec2534a 100644
    a b class BaseCacheTests(object): 
    295295            self.cache.set(key, value)
    296296            self.assertEqual(self.cache.get(key), value)
    297297
     298        for (key, value) in stuff.items():
     299            self.cache.delete(key)
     300            self.cache.add(key, value)
     301            self.assertEqual(self.cache.get(key), value)
     302
    298303    def test_binary_string(self):
    299304        # Binary strings should be cachable
    300305        from zlib import compress, decompress
Back to Top