Skip to content

Commit 71a8edb

Browse files
committed
Safe shape attribute access
1 parent 6ec6639 commit 71a8edb

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

jmespath/functions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737

3838

3939
def is_array(arg):
40-
return hasattr(arg, "__array__") and arg.shape != ()
40+
# Is trivially convertible to a non-scalar ndarray via array method. see:
41+
# https://numpy.org/doc/stable/user/basics.interoperability.html#the-array-method
42+
return hasattr(arg, "__array__") and arg.__array__().shape != ()
4143

4244

4345
def is_arraylike(arg):

0 commit comments

Comments
 (0)