Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-Authored-By: Eric Wieser <[email protected]>
  • Loading branch information
2 people authored and charris committed Sep 4, 2019
1 parent f66afd4 commit 1450488
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions numpy/core/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2477,10 +2477,11 @@ def __len__(self):
np.array([t])

@pytest.mark.skipif(sys.maxsize < 2 ** 31 + 1, reason='overflows 32-bit python')
@pytest.mark.skipif(sys.platform == 'win32', reason='overflows on windows')
@pytest.mark.skipif(sys.platform == 'win32' and sys.version_info[:2] < (3, 8),
reason='overflows on windows, fixed in bpo-16865')
def test_to_ctypes(self):
#gh-14214
arr = np.zeros((2 ** 31 + 1,), 'b')
assert(arr.size * arr.itemsize > 2 ** 31)
assert arr.size * arr.itemsize > 2 ** 31
c_arr = np.ctypeslib.as_ctypes(arr)
assert_equal(c_arr._length_, arr.size)
2 changes: 1 addition & 1 deletion numpy/ctypeslib.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def as_ctypes(obj):
# can't use `_dtype((ai["typestr"], ai["shape"]))` here, as it overflows
# dtype.itemsize (gh-14214)
ctype_scalar = as_ctypes_type(ai["typestr"])
result_type = _ctype_ndarray(ctype_scalar , ai['shape'])
result_type = _ctype_ndarray(ctype_scalar, ai["shape"])
result = result_type.from_address(addr)
result.__keep = obj
return result

0 comments on commit 1450488

Please sign in to comment.