Skip to content

Commit e8883c3

Browse files
committed
Update lib.pyx
Changed so c_is_list_like() returns false if __iter__() throws exception
1 parent 577bb72 commit e8883c3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pandas/_libs/lib.pyx

+4
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,10 @@ cdef bint c_is_list_like(object obj, bint allow_sets) except -1:
12061206
elif isinstance(obj, list):
12071207
return True
12081208
# then the generic implementation
1209+
try:
1210+
iter(obj)
1211+
except Exception:
1212+
return False
12091213
return (
12101214
# equiv: `isinstance(obj, abc.Iterable)`
12111215
getattr(obj, "__iter__", None) is not None and not isinstance(obj, type)

0 commit comments

Comments
 (0)