Commit 213f2946 authored by Malcolm Tredinnick's avatar Malcolm Tredinnick
Browse files

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.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8507 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent 97cb07c3
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ from django.contrib.sessions.models import Session
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 @@ class SessionStore(SessionBase):
                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 {}