You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by pc...@apache.org on 2018/01/07 21:48:16 UTC

[arrow] branch master updated: ARROW-1972: [Python] Import pyarrow in DeserializeObject.

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 95d894d  ARROW-1972: [Python] Import pyarrow in DeserializeObject.
95d894d is described below

commit 95d894da250ee7d5dfccb09e2d349e5748cc5fb8
Author: Robert Nishihara <ro...@gmail.com>
AuthorDate: Sun Jan 7 13:48:08 2018 -0800

    ARROW-1972: [Python] Import pyarrow in DeserializeObject.
    
    Author: Robert Nishihara <ro...@gmail.com>
    Author: Philipp Moritz <pc...@gmail.com>
    
    Closes #1463 from robertnishihara/segfaultfix and squashes the following commits:
    
    ec8a6c5 [Robert Nishihara] Add comment.
    6222340 [Philipp Moritz] fix tests, linting, add license
    3e969db [Robert Nishihara] Simplify tests.
    8aa3fca [Philipp Moritz] add regression test
    bfa0851 [Robert Nishihara] Import pyarrow in DeserializeObject.
---
 cpp/src/arrow/python/arrow_to_python.cc    |  1 +
 python/pyarrow/tests/deserialize_buffer.py | 26 ++++++++++++++++++++++++++
 python/pyarrow/tests/test_serialization.py | 14 ++++++++++++++
 3 files changed, 41 insertions(+)

diff --git a/cpp/src/arrow/python/arrow_to_python.cc b/cpp/src/arrow/python/arrow_to_python.cc
index ce539a5..c060ab8 100644
--- a/cpp/src/arrow/python/arrow_to_python.cc
+++ b/cpp/src/arrow/python/arrow_to_python.cc
@@ -284,6 +284,7 @@ Status DeserializeObject(PyObject* context, const SerializedPyObject& obj, PyObj
                          PyObject** out) {
   PyAcquireGIL lock;
   PyDateTime_IMPORT;
+  import_pyarrow();
   return DeserializeList(context, *obj.batch->column(0), 0, obj.batch->num_rows(), base,
                          obj, out);
 }
diff --git a/python/pyarrow/tests/deserialize_buffer.py b/python/pyarrow/tests/deserialize_buffer.py
new file mode 100644
index 0000000..982dc66
--- /dev/null
+++ b/python/pyarrow/tests/deserialize_buffer.py
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This file is called from a test in test_serialization.py.
+
+import sys
+
+import pyarrow as pa
+
+with open(sys.argv[1], 'rb') as f:
+    data = f.read()
+    pa.deserialize(data)
diff --git a/python/pyarrow/tests/test_serialization.py b/python/pyarrow/tests/test_serialization.py
index f245dc2..6116556 100644
--- a/python/pyarrow/tests/test_serialization.py
+++ b/python/pyarrow/tests/test_serialization.py
@@ -541,3 +541,17 @@ def test_deserialize_in_different_process():
     p.start()
     assert q.get().pattern == regex.pattern
     p.join()
+
+
+def test_deserialize_buffer_in_different_process():
+    import tempfile
+    import subprocess
+
+    f = tempfile.NamedTemporaryFile(delete=False)
+    b = pa.serialize(pa.frombuffer(b'hello')).to_buffer()
+    f.write(b.to_pybytes())
+    f.close()
+
+    dir_path = os.path.dirname(os.path.realpath(__file__))
+    python_file = os.path.join(dir_path, 'deserialize_buffer.py')
+    subprocess.check_call(['python', python_file, f.name])

-- 
To stop receiving notification emails like this one, please contact
['"commits@arrow.apache.org" <co...@arrow.apache.org>'].