Skip to content

Python 2.7 heterogeneous list unbox problem #4087

@stuartarchibald

Description

@stuartarchibald

Reporting a bug

Python 2.7 has an issue with this:

from numba import njit
import numpy as np

@njit
def foo(arg1, arg2):
    return 10

a = [np.array([ True]), np.array([False,  True, False])]
b = [np.array([1]), np.array([[ 0,  1,  2]])]

try:
    print(foo(1, b)) # ok, TypeError
except TypeError:
    pass
print(foo(a, b)) # broken

which gives:

test_pr_4077.py:15: RuntimeWarning: tp_compare didn't return -1 or -2 for exception                                             
  print(foo(a, b)) # broken                                                                                                     
Traceback (most recent call last):                                                                                              
  File "test_pr_4077.py", line 15, in <module>                                                                                  
    print(foo(a, b)) # broken                                                                                                   
SystemError: NULL result without error in PyObject_Call   

seems like it's the unbox of the second list that's the problem where it types it as a types.List(types.Array(int64, 1,'C')) but the second element is a 2d array. Why it only impacts the second use case and Python 2.7 (3.x is fine) needs more investigation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions