BUG: Error checks for the dtype shape.

Also creates a clean tuple for the shape tuple, instead of
passing potentially mutable objects through.

Closes gh-4009