Fix int bounds checking in asarray() to only happen when dtype=None
@@ -26,7 +26,7 @@ def asarray(obj: Union[float, NestedSequence[bool|int|float], SupportsDLPack, Su
raise NotImplementedError("The copy keyword argument to asarray is not yet implemented")
if isinstance(obj, ndarray) and (dtype is None or obj.dtype == dtype):
return obj
- if isinstance(obj, int) and (obj > 2**64 or obj < -2**63):
+ if dtype is None and isinstance(obj, int) and (obj > 2**64 or obj < -2**63):
# Give a better error message in this case. NumPy would convert this
# to an object array.
raise OverflowError("Integer out of bounds for array dtypes")
