setting array.dtype = x.dtype is only needed for custom dtypes, but throws an exception for object dtypes. I added a check to only set array.dtype for custom dtypes. I think every other dtype should be okay. Now that I think about it though, maybe the real issue is that np.asarray returns an array with a raw byte dtype, requiring the setting of array.dtype in the first place?