8000 Assertion error when running tests on Python 3.6 compiled in debug mode · Issue #7399 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Assertion error when running tests on Python 3.6 compiled in debug mode #7399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vstinner opened this issue Mar 9, 2016 · 5 comments
Closed

Comments

@vstinner
Copy link
Contributor
vstinner commented Mar 9, 2016

Hi,

I'm trying to run the numpy test suite on the development version of Python 3.6 with Python compiled in debug mode, but I had two issues:

  • Cython doesn't work on Python 3.6 anymore: http://bugs.python.org/issue26519
  • _convert_from_dict() function of numpy/core/src/multiarray/descriptor.c calls directly or indirectly PyObject_GetItem() with an exception set, it's no more allowed in debug mode, since PyObject_GetItem() may clear the current exception.

Following patch (incomplete, see the FIXME) works around assertion errors raised by the test suite:

diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c
index 03a4654..f9fd714 100644
--- a/numpy/core/src/multiarray/descriptor.c
+++ b/numpy/core/src/multiarray/descriptor.c
@@ -977,7 +977,10 @@ _convert_from_dict(PyObject *obj, int align)
      * Use PyMapping_GetItemString to support dictproxy objects as well.
      */
     names = Borrowed_PyMapping_GetItemString(obj, "names");
-    descrs = Borrowed_PyMapping_GetItemString(obj, "formats");
+    if (names)
+        descrs = Borrowed_PyMapping_GetItemString(obj, "formats");
+    else
+        descrs = NULL;
     if (!names || !descrs) {
         Py_DECREF(fields);
         PyErr_Clear();
@@ -985,8 +988,11 @@ _convert_from_dict(PyObject *obj, int align)
     }
     n = PyObject_Length(names);
     offsets = Borrowed_PyMapping_GetItemString(obj, "offsets");
+    if (!offsets) {
+        PyErr_Clear();
+    }
     titles = Borrowed_PyMapping_GetItemString(obj, "titles");
-    if (!offsets || !titles) {
+    if (!titles) {
         PyErr_Clear();
     }

@@ -1080,6 +1086,8 @@ _convert_from_dict(PyObject *obj, int align)
                         "with align=True",
                         (int)offset, (int)newdescr->alignment);
                 ret = NPY_FAIL;
+                /* FIXME: fix ref leaks! ind, tup, ... */
+                goto fail;
             }
             else if (offset + newdescr->elsize > totalsize) {
                 totalsize = offset + newdescr->elsize;

IMHO this function must be rewritten to handle exceptions differently: give up earlier. See also the issue #7360 which is a similar issue, but in a different C function of numpy (ufunc_generic_call).

@sh1ng
Copy link
sh1ng commented Feb 4, 2019

Any progress?

@vstinner
Copy link
Contributor Author

Any progress?

Sorry, I forgot this old issue and I didn't try again numpy on a Python compiled in debug mode. If nobody is interested, maybe simply close the issue.

@sh1ng
Copy link
sh1ng commented Feb 11, 2019

I faced something really similar on python3.6-debug and numpy 1.15.

@mattip
Copy link
Member
mattip commented Feb 25, 2019

using the python3.6-dbg provided with Ubuntu, HEAD runs tests cleanly for me. Which configuration flags are needed to cause this?

@seberg
Copy link
6E4F Member
seberg commented Aug 9, 2019

The error prone Borrowed_PyMapping_GetItemString was removed recently, and master as well as 1.16 at least run fine with python debug, so I will close this. Thanks all!

@seberg seberg closed this as completed Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0