Add empty recarray test, check for calloc fail
diff --git a/example/example20.py b/example/example20.py
index ed34548..d1bc942 100644
--- a/example/example20.py
+++ b/example/example20.py
@@ -17,3 +17,8 @@
assert arr.dtype == dtype
check_eq(arr, [(False, 0, 0.0), (True, 1, 1.5), (False, 2, 3.0)], dtype)
check_eq(arr, [(False, 0, 0.0), (True, 1, 1.5), (False, 2, 3.0)], base_dtype)
+
+arr = create_rec_simple(0)
+assert arr.dtype == dtype
+check_eq(arr, [], dtype)
+check_eq(arr, [], base_dtype)
diff --git a/include/pybind11/numpy.h b/include/pybind11/numpy.h
index 92ab116..6e9a629 100644
--- a/include/pybind11/numpy.h
+++ b/include/pybind11/numpy.h
@@ -116,6 +116,8 @@
auto buf_info = info;
if (!buf_info.ptr)
buf_info.ptr = std::calloc(info.size, info.itemsize);
+ if (!buf_info.ptr)
+ pybind11_fail("NumPy: failed to allocate memory for buffer");
auto view = py::memoryview(buf_info);
API& api = lookup_api();