Add an exported C function to get a typecode from a dtype.
Fix assert in response to numpy semantics changes.