Commit 0506facd authored by Paul McMillan's avatar Paul McMillan
Browse files

Fixed #16378. Locmem now uses pickle.HIGHEST_PROTOCOL for better compatibility...

Fixed #16378. Locmem now uses pickle.HIGHEST_PROTOCOL for better compatibility with other hash backends. Thanks aaugustin for the initial patch.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@17136 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent 4d975b4f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -102,7 +102,8 @@ class DatabaseCache(BaseDatabaseCache):
        exp = exp.replace(microsecond=0)
        if num > self._max_entries:
            self._cull(db, cursor, now)
        encoded = base64.encodestring(pickle.dumps(value, 2)).strip()
        pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL)
        encoded = base64.encodestring(pickled).strip()
        cursor.execute("SELECT cache_key, expires FROM %s "
                       "WHERE cache_key = %%s" % table, [key])
        try:
+6 −3
Original line number Diff line number Diff line
@@ -31,7 +31,8 @@ class LocMemCache(BaseCache):
            exp = self._expire_info.get(key)
            if exp is None or exp <= time.time():
                try:
                    self._set(key, pickle.dumps(value), timeout)
                    pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL)
                    self._set(key, pickled, timeout)
                    return True
                except pickle.PickleError:
                    pass
@@ -49,7 +50,8 @@ class LocMemCache(BaseCache):
                return default
            elif exp > time.time():
                try:
                    return pickle.loads(self._cache[key])
                    pickled = self._cache[key]
                    return pickle.loads(pickled)
                except pickle.PickleError:
                    return default
        finally:
@@ -78,7 +80,8 @@ class LocMemCache(BaseCache):
        self.validate_key(key)
        self._lock.writer_enters()
        try:
            self._set(key, pickle.dumps(value), timeout)
            pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL)
            self._set(key, pickled, timeout)
        except pickle.PickleError:
            pass
        finally:
+4 −0
Original line number Diff line number Diff line
@@ -501,6 +501,10 @@ Django 1.4 also includes several smaller improvements worth noting:
* Changed the default value for ``httponly`` on session cookies to
  ``True`` to help reduce the impact of potential XSS attacks.

* Changed the ``locmem`` cache backend to use
  ``pickle.HIGHEST_PROTOCOL`` for better compatibility with the other
  cache backends.

.. _backwards-incompatible-changes-1.4:

Backwards incompatible changes in 1.4