Skip to content

BUG: Cython and Py 3.10 have create issues when debugging #21008

@christian-steinmeyer

Description

@christian-steinmeyer

Describe the issue:

I'm experiencing some inconsistent behavior for np.dtype and np.iinfo. From within some code I cannot share here, I run the snippet below which fails with a TypeError (details also below). If I simply execute a main in which I call this function directly, it works however. Since I have a call stack of about 10 levels in the error case, I don't know, where exactly the difference is caused. If someone knows a way of easily and quickly isolating this issue, I'm happy to apply it.

The same code does not yield an error, if run in Python 3.8.5 and numpy 1.19.5. It does occur in python 3.10 and numpy versions 1.21.2, 1.22.0, 1.22.1, and 1.22.2.

Reproduce the code example:

import numpy as np

def my_func(dtype):
    dtype = np.dtype(dtype)
    iinfo = np.iinfo(dtype)  # <-- fails here

...
 my_func("uint_8")

Error message:

Traceback (most recent call last):
  File "/Users/<USER>/.virtualenvs/<PROJECT>/lib/python3.10/site-packages/numpy/core/getlimits.py", line 516, in __init__
    self.dtype = numeric.dtype(int_type)
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'numpy.dtype[uint8]'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  ...
    iinfo = np.iinfo(dtype)
  File "/Users/<USER>/.virtualenvs/<PROJECT>/lib/python3.10/site-packages/numpy/core/getlimits.py", line 518, in __init__
    self.dtype = numeric.dtype(type(int_type))
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'numpy._DTypeMeta'

NumPy/Python version information:

1.21.2 3.10.0 (default, Dec 7 2021, 09:05:11) [Clang 12.0.5 (clang-1205.0.22.9)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions