(cherry picked from commit
178e44de8f023be7a5dc400044ab61983b191f24)
Co-authored-by: Gregor <36135323+gege-hoho@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
...
SyntaxError: 'yield' outside function
+>>> yield from [1,2]
+Traceback (most recent call last):
+ ...
+SyntaxError: 'yield from' outside function
+
>>> def f(): x = yield = y
Traceback (most recent call last):
...
--- /dev/null
+Improve the :exc:`SyntaxError` message if the user tries to use
+:keyword:`yield from <yield>` outside a function.
break;
case YieldFrom_kind:
if (!_PyST_IsFunctionLike(c->u->u_ste)) {
- return compiler_error(c, loc, "'yield' outside function");
+ return compiler_error(c, loc, "'yield from' outside function");
}
if (c->u->u_scope_type == COMPILER_SCOPE_ASYNC_FUNCTION) {
return compiler_error(c, loc, "'yield from' inside async function");