-
-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Description
This came up in Dask (dask/dask#4387). We have an object (dask.delayed.Delayed) that duck-types method/attribute access to build a graph from user code. Unfortunately this means that when np.dtype tries to get the dtype attribute it succeeds but doesn't return a valid dtype (it returns another delayed object). This leads to recursion and eventually a segfault.
I'm able to reproduce his without dask as follows:
import numpy as np
class ShouldHaveNoDtype(object):
"""This class happens to have a dtype attribute, but it doesn't actually
meet the interface"""
@property
def dtype(self):
"""Has the attribute, but doesn't return a dtype, leading to recursion"""
return self
x = ShouldHaveNoDtype()
np.dtype(x)Metadata
Metadata
Assignees
Labels
No labels