Ticket #16378: 16378.diff
File 16378.diff, 2.1 KB (added by , 13 years ago) |
---|
-
django/core/cache/backends/locmem.py
31 31 exp = self._expire_info.get(key) 32 32 if exp is None or exp <= time.time(): 33 33 try: 34 self._set(key, pickle.dumps(value), timeout) 34 pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL) 35 self._set(key, pickled, timeout) 35 36 return True 36 37 except pickle.PickleError: 37 38 pass … … 49 50 return default 50 51 elif exp > time.time(): 51 52 try: 52 return pickle.loads(self._cache[key]) 53 pickled = self._cache[key] 54 return pickle.loads(pickled) 53 55 except pickle.PickleError: 54 56 return default 55 57 finally: … … 78 80 self.validate_key(key) 79 81 self._lock.writer_enters() 80 82 try: 81 self._set(key, pickle.dumps(value), timeout) 83 pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL) 84 self._set(key, pickled, timeout) 82 85 except pickle.PickleError: 83 86 pass 84 87 finally: -
django/core/cache/backends/db.py
79 79 exp = datetime.fromtimestamp(time.time() + timeout).replace(microsecond=0) 80 80 if num > self._max_entries: 81 81 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() 83 84 cursor.execute("SELECT cache_key, expires FROM %s WHERE cache_key = %%s" % table, [key]) 84 85 try: 85 86 result = cursor.fetchone()