From c0162a1f8ab5df6b8251217b677ad8a764be5b5c Mon Sep 17 00:00:00 2001 From: Nick Zaccardi Date: Wed, 27 Apr 2016 13:20:37 -0400 Subject: [PATCH] Fix unicode session behaviour --- flask_session/sessions.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/flask_session/sessions.py b/flask_session/sessions.py index c9024d77..053abe9d 100644 --- a/flask_session/sessions.py +++ b/flask_session/sessions.py @@ -9,6 +9,7 @@ :license: BSD, see LICENSE for more details. """ import time +import sys from datetime import datetime from uuid import uuid4 try: @@ -446,7 +447,7 @@ class Session(self.db.Model): id = self.db.Column(self.db.Integer, primary_key=True) session_id = self.db.Column(self.db.String(256), unique=True) - data = self.db.Column(self.db.Text) + data = self.db.Column(self.db.LargeBinary) expiry = self.db.Column(self.db.DateTime) def __init__(self, session_id, data, expiry): @@ -484,12 +485,8 @@ def open_session(self, app, request): self.db.session.commit() saved_session = None if saved_session: - try: - val = saved_session.data - data = self.serializer.loads(str(val)) - return self.session_class(data, sid=sid) - except: - return self.session_class(sid=sid) + data = self.serializer.loads(saved_session.data) + return self.session_class(data, sid=sid) return self.session_class(sid=sid) def save_session(self, app, session, response):