Skip to content

Commit 0330577

Browse files
base64 encode deferred payloads for better compatibility
1 parent 530a54b commit 0330577

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/google/appengine/ext/deferred/deferred.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def hello_world():
107107

108108

109109

110-
110+
import base64
111111
import http
112112
import logging
113113
import os
@@ -159,7 +159,7 @@ def run(data):
159159
PermanentTaskFailure if an error occurred during unpickling the task.
160160
"""
161161
try:
162-
func, args, kwds = pickle.loads(data)
162+
func, args, kwds = pickle.loads(base64.b64decode(data))
163163
except Exception as e:
164164
raise PermanentTaskFailure(e)
165165
else:
@@ -266,10 +266,10 @@ def serialize(obj, *args, **kwargs):
266266
"""
267267
curried = _curry_callable(obj, *args, **kwargs)
268268
if os.environ.get("DEFERRED_USE_CROSS_COMPATIBLE_PICKLE_PROTOCOL", False):
269-
protocol = 0
269+
protocol = 2
270270
else:
271271
protocol = pickle.HIGHEST_PROTOCOL
272-
return pickle.dumps(curried, protocol)
272+
return base64.b64encode(pickle.dumps(curried, protocol))
273273

274274

275275
def defer(obj, *args, **kwargs):

0 commit comments

Comments
 (0)