ARROW-5430: [Python] Raise ArrowInvalid for pyints larger than int64

Previously, this case would cause ArrowException: Unknown error, but
ArrowInvalid makes more sense and is more likely to be dealt with by
callers of pyarrow.array.
This commit is contained in:
Robin Kåveland Hansen committed 2019-06-03 14:55:20 +02:00
1 parent 518df0c149
commit b95aa02532
2 files changed
+9 -1

No files matched your search

+2 -1
View File
@@ -113,7 +113,8 @@ Status ConvertPyError(StatusCode code) {
code = StatusCode::KeyError;
} else if (PyErr_GivenExceptionMatches(exc_type, PyExc_TypeError)) {
code = StatusCode::TypeError;
} else if (PyErr_GivenExceptionMatches(exc_type, PyExc_ValueError)) {
} else if (PyErr_GivenExceptionMatches(exc_type, PyExc_ValueError) ||
PyErr_GivenExceptionMatches(exc_type, PyExc_OverflowError)) {
code = StatusCode::Invalid;
} else if (PyErr_GivenExceptionMatches(exc_type, PyExc_EnvironmentError)) {
code = StatusCode::IOError;
+7
View File
@@ -1374,3 +1374,10 @@ def test_numpy_string_overflow_to_chunked():
for val in chunk:
assert val.as_py() == values[value_index]
value_index += 1
def test_array_from_large_pyints():
# ARROW-5430
with pytest.raises(pa.ArrowInvalid):
# too large for int64 so dtype must be explicitly provided
pa.array([int(2 ** 63)])