Show More
@@ -11,14 +11,14 b' except:' | |||
|
11 | 11 | import pickle |
|
12 | 12 | |
|
13 | 13 | # IPython imports |
|
14 | from IPython.utils import py3compat | |
|
14 | from IPython.utils.py3compat import PY3, buffer_to_bytes_py2 | |
|
15 | 15 | from IPython.utils.data import flatten |
|
16 | 16 | from IPython.utils.pickleutil import ( |
|
17 | 17 | can, uncan, can_sequence, uncan_sequence, CannedObject, |
|
18 | 18 | istype, sequence_types, PICKLE_PROTOCOL, |
|
19 | 19 | ) |
|
20 | 20 | |
|
21 | if py3compat.PY3: | |
|
21 | if PY3: | |
|
22 | 22 | buffer = memoryview |
|
23 | 23 | |
|
24 | 24 | #----------------------------------------------------------------------------- |
@@ -105,10 +105,7 b' def deserialize_object(buffers, g=None):' | |||
|
105 | 105 | (newobj, bufs) : unpacked object, and the list of remaining unused buffers. |
|
106 | 106 | """ |
|
107 | 107 | bufs = list(buffers) |
|
108 | pobj = bufs.pop(0) | |
|
109 | if not isinstance(pobj, bytes): | |
|
110 | # a zmq message | |
|
111 | pobj = bytes(pobj) | |
|
108 | pobj = buffer_to_bytes_py2(bufs.pop(0)) | |
|
112 | 109 | canned = pickle.loads(pobj) |
|
113 | 110 | if istype(canned, sequence_types) and len(canned) < MAX_ITEMS: |
|
114 | 111 | for c in canned: |
@@ -161,11 +158,10 b' def unpack_apply_message(bufs, g=None, copy=True):' | |||
|
161 | 158 | Returns: original f,args,kwargs""" |
|
162 | 159 | bufs = list(bufs) # allow us to pop |
|
163 | 160 | assert len(bufs) >= 2, "not enough buffers!" |
|
164 | if not copy: | |
|
165 | for i in range(2): | |
|
166 | bufs[i] = bufs[i].bytes | |
|
167 |
f = |
|
|
168 | info = pickle.loads(bufs.pop(0)) | |
|
161 | pf = buffer_to_bytes_py2(bufs.pop(0)) | |
|
162 | f = uncan(pickle.loads(pf), g) | |
|
163 | pinfo = buffer_to_bytes_py2(bufs.pop(0)) | |
|
164 | info = pickle.loads(pinfo) | |
|
169 | 165 | arg_bufs, kwarg_bufs = bufs[:info['narg_bufs']], bufs[info['narg_bufs']:] |
|
170 | 166 | |
|
171 | 167 | args = [] |
@@ -17,7 +17,7 b' except ImportError:' | |||
|
17 | 17 | from . import codeutil # This registers a hook when it's imported |
|
18 | 18 | from . import py3compat |
|
19 | 19 | from .importstring import import_item |
|
20 | from .py3compat import string_types, iteritems | |
|
20 | from .py3compat import string_types, iteritems, buffer_to_bytes_py2 | |
|
21 | 21 | |
|
22 | 22 | from IPython.config import Application |
|
23 | 23 | from IPython.utils.log import get_logger |
@@ -260,8 +260,8 b' class CannedArray(CannedObject):' | |||
|
260 | 260 | from numpy import frombuffer |
|
261 | 261 | data = self.buffers[0] |
|
262 | 262 | if self.pickled: |
|
263 |
# |
|
|
264 | return pickle.loads(data) | |
|
263 | # we just pickled it | |
|
264 | return pickle.loads(buffer_to_bytes_py2(data)) | |
|
265 | 265 | else: |
|
266 | 266 | return frombuffer(data, dtype=self.dtype).reshape(self.shape) |
|
267 | 267 |
General Comments 0
You need to be logged in to leave comments.
Login now