summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorseberg <sebastian@sipsolutions.net>2016-10-04 10:34:54 +0200
committerGitHub <noreply@github.com>2016-10-04 10:34:54 +0200
commit9914e603fa620aa7d3ae9576772eb50df4b799ef (patch)
tree23f9a44b186118958f47ac72ea2f485abf170bb6 /numpy/core
parentb58bed888255ee1bc6610a30c2e96c38549062dd (diff)
parentfd6ff264a1c040dff63cfc913b6505d1b5a5457d (diff)
downloadnumpy-9914e603fa620aa7d3ae9576772eb50df4b799ef.tar.gz
Merge pull request #8114 from pv/bugfix
BUG: core: add missing error check after PyLong_AsSsize_t
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/src/multiarray/multiarraymodule.c3
-rw-r--r--numpy/core/tests/test_mem_overlap.py6
2 files changed, 9 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index fb646b336..620f8d109 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -3981,6 +3981,9 @@ array_shares_memory_impl(PyObject *args, PyObject *kwds, Py_ssize_t default_max_
}
else if (PyLong_Check(max_work_obj)) {
max_work = PyLong_AsSsize_t(max_work_obj);
+ if (PyErr_Occurred()) {
+ goto fail;
+ }
}
#if !defined(NPY_PY3K)
else if (PyInt_Check(max_work_obj)) {
diff --git a/numpy/core/tests/test_mem_overlap.py b/numpy/core/tests/test_mem_overlap.py
index 5a1f6ac98..acca53856 100644
--- a/numpy/core/tests/test_mem_overlap.py
+++ b/numpy/core/tests/test_mem_overlap.py
@@ -348,6 +348,12 @@ def test_shares_memory_api():
assert_raises(np.TooHardError, np.shares_memory, a, b, max_work=long(1))
+def test_may_share_memory_bad_max_work():
+ x = np.zeros([1])
+ assert_raises(OverflowError, np.may_share_memory, x, x, max_work=10**100)
+ assert_raises(OverflowError, np.shares_memory, x, x, max_work=10**100)
+
+
def test_internal_overlap_diophantine():
def check(A, U, exists=None):
X = solve_diophantine(A, U, 0, require_ub_nontrivial=1)