← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-pickle-loads-bytes into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-pickle-loads-bytes into launchpad:master.

Commit message:
Pass bytes to pickle.loads

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/393768
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-pickle-loads-bytes into launchpad:master.
diff --git a/lib/launchpad_loggerhead/session.py b/lib/launchpad_loggerhead/session.py
index cf4516b..f2d3e9b 100644
--- a/lib/launchpad_loggerhead/session.py
+++ b/lib/launchpad_loggerhead/session.py
@@ -7,6 +7,7 @@
 import pickle
 
 from paste.auth.cookie import AuthCookieHandler
+import six
 
 
 class SessionHandler(object):
@@ -47,7 +48,8 @@ class SessionHandler(object):
         pickle.
         """
         if self.session_var in environ:
-            session = pickle.loads(environ[self.session_var])
+            session = pickle.loads(six.ensure_binary(
+                environ[self.session_var], encoding="ISO-8859-1"))
         else:
             session = {}
         existed = bool(session)
diff --git a/lib/lp/services/webapp/pgsession.py b/lib/lp/services/webapp/pgsession.py
index 1940fac..5d110af 100644
--- a/lib/lp/services/webapp/pgsession.py
+++ b/lib/lp/services/webapp/pgsession.py
@@ -188,7 +188,7 @@ class PGSessionPkgData(MutableMapping, PGSessionBase):
         result = self.store.execute(
             query, (self.session_data.hashed_client_id, self.product_id))
         for key, pickled_value in result:
-            value = pickle.loads(str(pickled_value))
+            value = pickle.loads(bytes(pickled_value))
             self._data_cache[key] = value
 
     def __getitem__(self, key):