Ticket #16378: 16378.diff

File 16378.diff, 2.1 KB (added by Aymeric Augustin, 13 years ago)
  • django/core/cache/backends/locmem.py

     
    3131            exp = self._expire_info.get(key)
    3232            if exp is None or exp <= time.time():
    3333                try:
    34                     self._set(key, pickle.dumps(value), timeout)
     34                    pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL)
     35                    self._set(key, pickled, timeout)
    3536                    return True
    3637                except pickle.PickleError:
    3738                    pass
     
    4950                return default
    5051            elif exp > time.time():
    5152                try:
    52                     return pickle.loads(self._cache[key])
     53                    pickled = self._cache[key]
     54                    return pickle.loads(pickled)
    5355                except pickle.PickleError:
    5456                    return default
    5557        finally:
     
    7880        self.validate_key(key)
    7981        self._lock.writer_enters()
    8082        try:
    81             self._set(key, pickle.dumps(value), timeout)
     83            pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL)
     84            self._set(key, pickled, timeout)
    8285        except pickle.PickleError:
    8386            pass
    8487        finally:
  • django/core/cache/backends/db.py

     
    7979        exp = datetime.fromtimestamp(time.time() + timeout).replace(microsecond=0)
    8080        if num > self._max_entries:
    8181            self._cull(db, cursor, now)
    82         encoded = base64.encodestring(pickle.dumps(value, 2)).strip()
     82        pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL)
     83        encoded = base64.encodestring(pickled).strip()
    8384        cursor.execute("SELECT cache_key, expires FROM %s WHERE cache_key = %%s" % table, [key])
    8485        try:
    8586            result = cursor.fetchone()
Back to Top