diff options
| author | Gary Wilson Jr <gary.wilson@gmail.com> | 2007-11-21 19:54:58 +0000 |
|---|---|---|
| committer | Gary Wilson Jr <gary.wilson@gmail.com> | 2007-11-21 19:54:58 +0000 |
| commit | 900811f4013ec0663e439dbdabf5f0ea266cf501 (patch) | |
| tree | de97ec04256efbe2b9fb823d0240b5418fdae33e | |
| parent | 2e9e36e29744ca638ca34799d79a6eb638a2d822 (diff) | |
Fixed #5981 -- Fixed failing regression test when using locmem cache backend. Changed `add` to pickle the value as is done in `set`. Based on patch from mattmcc.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6709 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/core/cache/backends/locmem.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/django/core/cache/backends/locmem.py b/django/core/cache/backends/locmem.py index 5998f7bfd5..2d74e2b132 100644 --- a/django/core/cache/backends/locmem.py +++ b/django/core/cache/backends/locmem.py @@ -16,8 +16,12 @@ class CacheClass(SimpleCacheClass): def add(self, key, value, timeout=None): self._lock.writer_enters() + # Python 2.3 and 2.4 don't allow combined try-except-finally blocks. try: - SimpleCacheClass.add(self, key, value, timeout) + try: + super(CacheClass, self).add(key, pickle.dumps(value), timeout) + except pickle.PickleError: + pass finally: self._lock.writer_leaves() @@ -49,6 +53,7 @@ class CacheClass(SimpleCacheClass): def set(self, key, value, timeout=None): self._lock.writer_enters() + # Python 2.3 and 2.4 don't allow combined try-except-finally blocks. try: try: super(CacheClass, self).set(key, pickle.dumps(value), timeout) |
