You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by uw...@apache.org on 2018/01/25 22:40:11 UTC
[arrow] branch master updated: ARROW-2017: [Python] Use unsigned
PyLong API for uint64 values over int64 range
This is an automated email from the ASF dual-hosted git repository.
uwe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new bfce44b ARROW-2017: [Python] Use unsigned PyLong API for uint64 values over int64 range
bfce44b is described below
commit bfce44beb918807b17b5c94a6c4efdb3d7ff6e5f
Author: Wes McKinney <we...@twosigma.com>
AuthorDate: Thu Jan 25 23:39:29 2018 +0100
ARROW-2017: [Python] Use unsigned PyLong API for uint64 values over int64 range
Author: Wes McKinney <we...@twosigma.com>
Closes #1504 from wesm/ARROW-2017 and squashes the following commits:
56e67dc [Wes McKinney] Use unsigned PyLong API for uint64 values over int64 range
---
cpp/src/arrow/python/builtin_convert.cc | 2 +-
python/pyarrow/tests/test_array.py | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/cpp/src/arrow/python/builtin_convert.cc b/cpp/src/arrow/python/builtin_convert.cc
index cd88d55..0879b3f 100644
--- a/cpp/src/arrow/python/builtin_convert.cc
+++ b/cpp/src/arrow/python/builtin_convert.cc
@@ -511,7 +511,7 @@ class UInt32Converter : public TypedConverterVisitor<UInt32Builder, UInt32Conver
class UInt64Converter : public TypedConverterVisitor<UInt64Builder, UInt64Converter> {
public:
Status AppendItem(const OwnedRef& item) {
- const auto val = static_cast<int64_t>(PyLong_AsLongLong(item.obj()));
+ const auto val = static_cast<int64_t>(PyLong_AsUnsignedLongLong(item.obj()));
RETURN_IF_PYERROR();
return typed_builder_->Append(val);
}
diff --git a/python/pyarrow/tests/test_array.py b/python/pyarrow/tests/test_array.py
index fa38c92..2d99111 100644
--- a/python/pyarrow/tests/test_array.py
+++ b/python/pyarrow/tests/test_array.py
@@ -485,6 +485,12 @@ def test_logical_type(type, expected):
assert get_logical_type(type) == expected
+def test_array_uint64_from_py_over_range():
+ arr = pa.array([2 ** 63], type=pa.uint64())
+ expected = pa.array(np.array([2 ** 63], dtype='u8'))
+ assert arr.equals(expected)
+
+
def test_array_conversions_no_sentinel_values():
arr = np.array([1, 2, 3, 4], dtype='int8')
refcount = sys.getrefcount(arr)
--
To stop receiving notification emails like this one, please contact
uwe@apache.org.