Browse files

Fixed #17810 (again). Catch session key errors.

The previous commit didn't work with PyLibMC.
This solution appears to be the best compromise
at this point in the 1.4 release cycle.



git-svn-id: http://code.djangoproject.com/svn/django/trunk@17797 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 46871eb commit f356a2e52fd0c36045b960412196552944a57888 @aaugustin aaugustin committed Mar 23, 2012
Showing with 6 additions and 8 deletions.
  1. +3 −4 django/contrib/sessions/backends/cache.py
  2. +3 −4 django/contrib/sessions/backends/cached_db.py
View
7 django/contrib/sessions/backends/cache.py
@@ -19,10 +19,9 @@ def cache_key(self):
def load(self):
try:
session_data = self._cache.get(self.cache_key, None)
- except Exception, e:
- e_type = str(type(e))
- if e_type != "<class 'memcache.MemcachedKeyLengthError'>":
- raise e
+ except Exception:
+ # Some backends (e.g. memcache) raise an exception on invalid
+ # cache keys. If this happens, reset the session. See #17810.
session_data = None
if session_data is not None:
return session_data
View
7 django/contrib/sessions/backends/cached_db.py
@@ -24,10 +24,9 @@ def cache_key(self):
def load(self):
try:
data = cache.get(self.cache_key, None)
- except Exception, e:
- e_type = str(type(e))
- if e_type != "<class 'memcache.MemcachedKeyLengthError'>":
- raise e
+ except Exception:
+ # Some backends (e.g. memcache) raise an exception on invalid
+ # cache keys. If this happens, reset the session. See #17810.
data = None
if data is None:
data = super(SessionStore, self).load()

0 comments on commit f356a2e

Please sign in to comment.