Skip to content

Commit 8271576

Browse files
committed
change error type and avoid infinite loop
1 parent 91100f7 commit 8271576

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pandas/core/internals/blocks.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -994,13 +994,14 @@ def putmask(self, mask, new, align=True, inplace=False, axis=0,
994994
# for 2D cases
995995
if ((is_list_like(new) and np.any(mask[mask]) and
996996
getattr(new, 'ndim', 1) == 1)):
997-
# GH 19266 and GH 21977
998997
if not (mask.shape[-1] == len(new) or
999998
mask[mask].shape[-1] == len(new) or
1000999
len(new) == 1):
1001-
raise NotImplementedError(
1002-
"Replace with array-like of mismatch length to masked "
1003-
"array is not supported.")
1000+
# GH 19266 and GH 21977
1001+
# ValueError triggers try except block in Block.replace
1002+
# causing RecursionError
1003+
raise Exception("cannot assign mismatch length "
1004+
"to masked array")
10041005

10051006
np.putmask(new_values, mask, new)
10061007

0 commit comments

Comments
 (0)