summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-03-23 16:14:46 +0000
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-03-23 16:14:46 +0000
commitf356a2e52fd0c36045b960412196552944a57888 (patch)
tree423523a02320865e0fa41ba5114e3fac66023dd1
parent46871eb1bb37e0c34f4498e671f6418f9487d69f (diff)
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
-rw-r--r--django/contrib/sessions/backends/cache.py7
-rw-r--r--django/contrib/sessions/backends/cached_db.py7
2 files changed, 6 insertions, 8 deletions
diff --git a/django/contrib/sessions/backends/cache.py b/django/contrib/sessions/backends/cache.py
index 7c3eecd425..467d5f1265 100644
--- a/django/contrib/sessions/backends/cache.py
+++ b/django/contrib/sessions/backends/cache.py
@@ -19,10 +19,9 @@ class SessionStore(SessionBase):
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
diff --git a/django/contrib/sessions/backends/cached_db.py b/django/contrib/sessions/backends/cached_db.py
index db0d3515b1..ff6076df77 100644
--- a/django/contrib/sessions/backends/cached_db.py
+++ b/django/contrib/sessions/backends/cached_db.py
@@ -24,10 +24,9 @@ class SessionStore(DBStore):
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()