Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit f356a2e52fd0c36045b960412196552944a57888 1 parent 46871eb
Aymeric Augustin authored March 23, 2012
7  django/contrib/sessions/backends/cache.py
@@ -19,10 +19,9 @@ def cache_key(self):
19 19
     def load(self):
20 20
         try:
21 21
             session_data = self._cache.get(self.cache_key, None)
22  
-        except Exception, e:
23  
-            e_type = str(type(e))
24  
-            if e_type != "<class 'memcache.MemcachedKeyLengthError'>":
25  
-                raise e
  22
+        except Exception:
  23
+            # Some backends (e.g. memcache) raise an exception on invalid
  24
+            # cache keys. If this happens, reset the session. See #17810.
26 25
             session_data = None
27 26
         if session_data is not None:
28 27
             return session_data
7  django/contrib/sessions/backends/cached_db.py
@@ -24,10 +24,9 @@ def cache_key(self):
24 24
     def load(self):
25 25
         try:
26 26
             data = cache.get(self.cache_key, None)
27  
-        except Exception, e:
28  
-            e_type = str(type(e))
29  
-            if e_type != "<class 'memcache.MemcachedKeyLengthError'>":
30  
-                raise e
  27
+        except Exception:
  28
+            # Some backends (e.g. memcache) raise an exception on invalid
  29
+            # cache keys. If this happens, reset the session. See #17810.
31 30
             data = None
32 31
         if data is None:
33 32
             data = super(SessionStore, self).load()

0 notes on commit f356a2e

Please sign in to comment.
Something went wrong with that request. Please try again.