diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-08-18 05:42:12 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-08-18 05:42:12 -0700 |
commit | c8312982066dd3a5f43a14934a353cc80159c985 (patch) | |
tree | a3490d52767a6d076d96526e4a3f4eca0bd00eb6 /numpy/core | |
parent | 0a6217dc82fb1585d99dd29f8e1451be47386003 (diff) | |
parent | d0bdae43724342abea17ed89f9cd6a96d11fc256 (diff) | |
download | numpy-c8312982066dd3a5f43a14934a353cc80159c985.tar.gz |
Merge pull request #3631 from charris/fix-reference-leak
Fix reference leak
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/src/multiarray/conversion_utils.c | 3 | ||||
-rw-r--r-- | numpy/core/tests/test_numeric.py | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/conversion_utils.c b/numpy/core/src/multiarray/conversion_utils.c index a17156e53..8ce7bb74d 100644 --- a/numpy/core/src/multiarray/conversion_utils.c +++ b/numpy/core/src/multiarray/conversion_utils.c @@ -99,6 +99,7 @@ PyArray_IntpConverter(PyObject *obj, PyArray_Dims *seq) /* * After the deprecation the PyNumber_Check could be replaced * by PyIndex_Check. + * FIXME 1.9 ? */ len = 1; } @@ -922,8 +923,8 @@ PyArray_IntpFromIndexSequence(PyObject *seq, npy_intp *vals, npy_intp maxvals) return -1; } - vals[i] = PyArray_PyIntAsIntp(op); + Py_DECREF(op); if(vals[i] == -1) { err = PyErr_Occurred(); if (err && diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py index 341884f04..fdf1c1ac1 100644 --- a/numpy/core/tests/test_numeric.py +++ b/numpy/core/tests/test_numeric.py @@ -1546,6 +1546,20 @@ class TestCreationFuncs(TestCase): self.check_function(np.full, 0) self.check_function(np.full, 1) + def test_for_reference_leak(self): + # Make sure we have an object for reference + dim = 1 + beg = sys.getrefcount(dim) + np.zeros([dim]*10) + assert_(sys.getrefcount(dim) == beg) + np.ones([dim]*10) + assert_(sys.getrefcount(dim) == beg) + np.empty([dim]*10) + assert_(sys.getrefcount(dim) == beg) + np.full([dim]*10, 0) + assert_(sys.getrefcount(dim) == beg) + + class TestLikeFuncs(TestCase): '''Test ones_like, zeros_like, empty_like and full_like''' |