Avoid a null-pointer dereference in _tri.cpp

Found using the clang static analyzer:
if PyArray_ContiguousFromObject returns NULL,
PyArray_NDIM(x) causes a null-pointer dereference.

@ianthomas23: could you review this?