Author: mtredinnick
Date: 2008-08-23 17:59:04 -0500 (Sat, 23 Aug 2008)
New Revision: 8507

Modified:
   django/trunk/django/contrib/sessions/backends/db.py
Log:
Avoid a crash when unencoding session data for the db backend. This is required
because some configurations of MySQL (with utf8_bin collation) will return
bytestring, rather than unicode data, which was causing problems previously.

Refs #8340.


Modified: django/trunk/django/contrib/sessions/backends/db.py
===================================================================
--- django/trunk/django/contrib/sessions/backends/db.py 2008-08-23 22:25:40 UTC 
(rev 8506)
+++ django/trunk/django/contrib/sessions/backends/db.py 2008-08-23 22:59:04 UTC 
(rev 8507)
@@ -3,6 +3,7 @@
 from django.contrib.sessions.backends.base import SessionBase, CreateError
 from django.core.exceptions import SuspiciousOperation
 from django.db import IntegrityError, transaction
+from django.utils.encoding import force_unicode
 
 class SessionStore(SessionBase):
     """
@@ -14,7 +15,7 @@
                 session_key = self.session_key,
                 expire_date__gt=datetime.datetime.now()
             )
-            return self.decode(s.session_data)
+            return self.decode(force_unicode(s.session_data))
         except (Session.DoesNotExist, SuspiciousOperation):
             self.create()
             return {}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to