diff --git a/bindings/pyroot/src/Pythonize.cxx b/bindings/pyroot/src/Pythonize.cxx index 483cbfeddab1658a839d66c156a3ca79f4f2c6ab..bd73790b1412890ee1c10dc386f814854fa93013 100644 --- a/bindings/pyroot/src/Pythonize.cxx +++ b/bindings/pyroot/src/Pythonize.cxx @@ -2334,7 +2334,9 @@ namespace { // Pointer auto ptr = reinterpret_cast<unsigned long long>(cobj->data()); - if (cobj->empty()) ptr = 1; // Numpy breaks for data pointer of 0 even though the array is empty. + // Numpy breaks for data pointer of 0 even though the array is empty. + // We set the pointer to 1 but the value itself is arbitrary and never accessed. + if (cobj->empty()) ptr = 1; auto pyptr = PyLong_FromUnsignedLongLong(ptr); auto pydata = PyTuple_Pack(2, pyptr, Py_False); PyDict_SetItemString(dict, "data", pydata); diff --git a/bindings/pyroot_experimental/PyROOT/python/ROOT/pythonization/_rvec.py b/bindings/pyroot_experimental/PyROOT/python/ROOT/pythonization/_rvec.py index 612c33370bb0972df8402dc935f8d64af050e7d0..aa1c6ac6ca552dc408bd478bcefff42846a3e1be 100644 --- a/bindings/pyroot_experimental/PyROOT/python/ROOT/pythonization/_rvec.py +++ b/bindings/pyroot_experimental/PyROOT/python/ROOT/pythonization/_rvec.py @@ -33,7 +33,9 @@ def get_array_interface(self): dtype_size = GetSizeOfType(dtype) endianess = GetEndianess() size = self.size() - if self.empty(): # Numpy sees a null pointer as error even though the data is never accessed. + # Numpy breaks for data pointer of 0 even though the array is empty. + # We set the pointer to 1 but the value itself is arbitrary and never accessed. + if self.empty(): pointer = 1 else: pointer = GetVectorDataPointer(self, cppname)