Skip to content

Commit c867004

Browse files
committed
Check if type is iterable for yield from statement
1 parent ea1f4f3 commit c867004

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

monic/expressions/interpreter.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,13 @@ def func(*call_args, **call_kwargs):
14391439
except YieldValue as yv:
14401440
yield yv.value
14411441
except YieldFromValue as yfv:
1442+
try:
1443+
iter(yfv.iterator)
1444+
except TypeError as e:
1445+
raise TypeError(
1446+
"cannot 'yield from' a non-iterator of "
1447+
f"type {type(yfv.iterator).__name__}"
1448+
) from e
14421449
yield from yfv.iterator
14431450
except StopIteration:
14441451
return None

0 commit comments

Comments
 (0)