This is an automated email from the ASF dual-hosted git repository.
pcmoritz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new f84af8f ARROW-2065: [Python] Fix bug in SerializationContext.clone().
f84af8f is described below
commit f84af8f79c0793f304743298cf40daf3a0bbf042
Author: Robert Nishihara <[email protected]>
AuthorDate: Thu Feb 1 13:59:05 2018 -0800
ARROW-2065: [Python] Fix bug in SerializationContext.clone().
One issue is that I don't think the test fails on the current master.
Author: Robert Nishihara <[email protected]>
Closes #1539 from robertnishihara/fixclonebug and squashes the following
commits:
61534b8b [Robert Nishihara] Fix test.
35a559a8 [Robert Nishihara] Fix bug in which SerializationContext.clone()
doesn't copy a field.
---
python/pyarrow/serialization.pxi | 1 +
python/pyarrow/tests/test_serialization.py | 27 +++++++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/python/pyarrow/serialization.pxi b/python/pyarrow/serialization.pxi
index e7a3990..44bf877 100644
--- a/python/pyarrow/serialization.pxi
+++ b/python/pyarrow/serialization.pxi
@@ -89,6 +89,7 @@ cdef class SerializationContext:
result = SerializationContext()
result.type_to_type_id = self.type_to_type_id.copy()
result.whitelisted_types = self.whitelisted_types.copy()
+ result.types_to_pickle = self.types_to_pickle.copy()
result.custom_serializers = self.custom_serializers.copy()
result.custom_deserializers = self.custom_deserializers.copy()
result.pickle_serializer = self.pickle_serializer
diff --git a/python/pyarrow/tests/test_serialization.py
b/python/pyarrow/tests/test_serialization.py
index 7a42010..23059e1 100644
--- a/python/pyarrow/tests/test_serialization.py
+++ b/python/pyarrow/tests/test_serialization.py
@@ -248,6 +248,33 @@ def large_memory_map(tmpdir_factory, size=100*1024*1024):
return path
+def test_clone():
+ context = pa.SerializationContext()
+
+ class Foo(object):
+ pass
+
+ def custom_serializer(obj):
+ return 0
+
+ def custom_deserializer(serialized_obj):
+ return (serialized_obj, 'a')
+
+ context.register_type(Foo, 'Foo', custom_serializer=custom_serializer,
+ custom_deserializer=custom_deserializer)
+
+ new_context = context.clone()
+
+ f = Foo()
+ serialized = pa.serialize(f, context=context)
+ deserialized = serialized.deserialize(context=context)
+ assert deserialized == (0, 'a')
+
+ serialized = pa.serialize(f, context=new_context)
+ deserialized = serialized.deserialize(context=new_context)
+ assert deserialized == (0, 'a')
+
+
def test_primitive_serialization(large_buffer):
for obj in PRIMITIVE_OBJECTS:
serialization_roundtrip(obj, large_buffer)
--
To stop receiving notification emails like this one, please contact
[email protected].