Skip to content

BUG: dot can create a 0d array with dtype=object that can assert in ufuncs #23492

@mattip

Description

@mattip

While debugging #15186, I discovered that the following code hit an assert(in1 != NULL) in the inner loop:

>>> a = np.array([0], dtype=object)
>>> b = np.tensordot(a[1:], a[:1], axes=((0,), (0,))
>>> b
array(None, dtype=object)
>>> b.shape
()
>>> b += 1
python: ../numpy/core/src/umath/loops.c.src:259: PyUFunc_OO_O: Assertion `in1 != NULL' failed

The assert is only active when debugging. This does not segfault:

>>> c = np.array(None, dtype=object)
>>> c += 1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions