mirror of
https://github.com/apache/arrow.git
synced 2026-10-29 09:05:47 +08:00
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:
1 parent
518df0c149
commit
b95aa02532
2 files changed
+9
-1
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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)])
|
||||
Reference in new issue
Block a user