Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ipykernel/pickleutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from ipython_genutils import py3compat
from ipython_genutils.importstring import import_item
from ipython_genutils.py3compat import string_types, iteritems, buffer_to_bytes_py2
from ipython_genutils.py3compat import string_types, iteritems, buffer_to_bytes, buffer_to_bytes_py2

from . import codeutil # This registers a hook when it's imported

Expand Down Expand Up @@ -290,7 +290,8 @@ def get_object(self, g=None):


class CannedBytes(CannedObject):
wrap = bytes
wrap = staticmethod(buffer_to_bytes)

def __init__(self, obj):
self.buffers = [obj]

Expand Down
8 changes: 7 additions & 1 deletion ipykernel/tests/test_pickleutil.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

import os
import pickle

import nose.tools as nt
Expand Down Expand Up @@ -59,4 +60,9 @@ def foo():
bar = loads(pfoo)
nt.assert_equal(foo(), bar())


def test_uncan_bytes_buffer():
data = b'data'
canned = can(data)
canned.buffers = [memoryview(buf) for buf in canned.buffers]
out = uncan(canned)
nt.assert_equal(out, data)