uqfoundation/dill

NumPy 2.0.0 test regression: `test_diff.py`: `RecursionError: maximum recursion depth exceeded`

mgorny opened this issue · 3 comments

When NumPy 2.0.0 is installed, test_diff.py crashes with a RecursionError:

$ python dill/tests/test_diff.py 
Traceback (most recent call last):
  File "/tmp/dill/dill/tests/test_diff.py", line 9, in <module>
    from dill import __diff as diff
  File "/tmp/dill/.tox/py312/lib/python3.12/site-packages/dill/__diff.py", line 233, in <module>
    memorise(mod)
  File "/tmp/dill/.tox/py312/lib/python3.12/site-packages/dill/__diff.py", line 111, in memorise
    [mem(value) for key, value in g.items()]
     ^^^^^^^^^^
  File "/tmp/dill/.tox/py312/lib/python3.12/site-packages/dill/__diff.py", line 111, in memorise
    [mem(value) for key, value in g.items()]
     ^^^^^^^^^^
  File "/tmp/dill/.tox/py312/lib/python3.12/site-packages/dill/__diff.py", line 97, in memorise
    s = get_seq(obj)
        ^^^^^^^^^^^^
  File "/tmp/dill/.tox/py312/lib/python3.12/site-packages/dill/__diff.py", line 64, in get_seq
    elif HAS_NUMPY and o_type in (numpy.ndarray, numpy.ma.core.MaskedConstant):
                                                 ^^^^^^^^
  File "/tmp/dill/.tox/py312/lib/python3.12/site-packages/numpy/__init__.py", line 343, in __getattr__
    import numpy.ma as ma
  File "/tmp/dill/.tox/py312/lib/python3.12/site-packages/dill/__diff.py", line 220, in _imp
    mod = __import__(*args, **kwds)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/dill/.tox/py312/lib/python3.12/site-packages/numpy/ma/__init__.py", line 42, in <module>
    from . import core
  File "/tmp/dill/.tox/py312/lib/python3.12/site-packages/dill/__diff.py", line 223, in _imp
    memorise(sys.modules[m])
  File "/tmp/dill/.tox/py312/lib/python3.12/site-packages/dill/__diff.py", line 111, in memorise
    [mem(value) for key, value in g.items()]
     ^^^^^^^^^^
  File "/tmp/dill/.tox/py312/lib/python3.12/site-packages/dill/__diff.py", line 97, in memorise
    s = get_seq(obj)
        ^^^^^^^^^^^^
  File "/tmp/dill/.tox/py312/lib/python3.12/site-packages/dill/__diff.py", line 64, in get_seq
    elif HAS_NUMPY and o_type in (numpy.ndarray, numpy.ma.core.MaskedConstant):
                                                 ^^^^^^^^
  File "/tmp/dill/.tox/py312/lib/python3.12/site-packages/numpy/__init__.py", line 343, in __getattr__
    import numpy.ma as ma
  File "/tmp/dill/.tox/py312/lib/python3.12/site-packages/numpy/__init__.py", line 343, in __getattr__
    import numpy.ma as ma
  File "/tmp/dill/.tox/py312/lib/python3.12/site-packages/numpy/__init__.py", line 343, in __getattr__
    import numpy.ma as ma
  [Previous line repeated 967 more times]
  File "/tmp/dill/.tox/py312/lib/python3.12/site-packages/dill/__diff.py", line 220, in _imp
    mod = __import__(*args, **kwds)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 471, in _lock_unlock_module
  File "<frozen importlib._bootstrap>", line 311, in acquire
  File "<frozen importlib._bootstrap>", line 170, in __enter__
  File "<frozen importlib._bootstrap>", line 132, in setdefault
RecursionError: maximum recursion depth exceeded

Thanks!