1
0
mirror of https://github.com/django/django.git synced 2024-12-23 09:36:06 +00:00

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
This commit is contained in:
Malcolm Tredinnick 2008-08-23 22:59:04 +00:00
parent 97cb07c3a1
commit 213f294638

View File

@ -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 {}