From b6b2b03950b077c1d75fe5be710f18ea88b688dd Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Mon, 8 Aug 2016 16:29:59 -0700 Subject: [PATCH] throw proper error if numpy array that contains object is serialized --- python/src/pynumbuf/adapters/numpy.cc | 6 +++++- python/test/runtest.py | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/python/src/pynumbuf/adapters/numpy.cc b/python/src/pynumbuf/adapters/numpy.cc index 45c4149a4..fb74db28f 100644 --- a/python/src/pynumbuf/adapters/numpy.cc +++ b/python/src/pynumbuf/adapters/numpy.cc @@ -1,5 +1,7 @@ #include "numpy.h" +#include + #include using namespace arrow; @@ -95,7 +97,9 @@ Status SerializeArray(PyArrayObject* array, SequenceBuilder& builder) { RETURN_NOT_OK(builder.AppendTensor(dims, reinterpret_cast(data))); break; default: - DCHECK(false) << "numpy data type not recognized: " << dtype; + std::stringstream stream; + stream << "numpy data type not recognized: " << dtype; + return Status::NotImplemented(stream.str()); } Py_XDECREF(contiguous); return Status::OK(); diff --git a/python/test/runtest.py b/python/test/runtest.py index 14545117d..1bb4addba 100644 --- a/python/test/runtest.py +++ b/python/test/runtest.py @@ -47,6 +47,13 @@ class SerializationTests(unittest.TestCase): for t in ["int8", "uint8", "int16", "uint16", "int32", "uint32", "float32", "float64"]: self.numpyTest(t) + def testNumpyObject(self): + a = np.array([np.zeros((2,2))], dtype=object) + try: + x = self.roundTripTest([a]) + except: + pass + def testRay(self): for obj in TEST_OBJECTS: self.roundTripTest([obj])