Skip to content

Commit 7f804fd

Browse files
authored
Merge pull request #3202 from WarriorOfWire/require_await_in_async
Require await in async
2 parents f4f2018 + a6b5870 commit 7f804fd

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

locale/circuitpython.pot

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2020-07-21 18:43-0700\n"
11+
"POT-Creation-Date: 2020-07-24 19:58-0700\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -110,10 +110,6 @@ msgstr ""
110110
msgid "'%q' argument required"
111111
msgstr ""
112112

113-
#: py/objarray.c
114-
msgid "'%q' object is not bytes-like"
115-
msgstr ""
116-
117113
#: py/emitinlinethumb.c py/emitinlinextensa.c
118114
#, c-format
119115
msgid "'%s' expects a label"
@@ -219,11 +215,11 @@ msgid "'align' requires 1 argument"
219215
msgstr ""
220216

221217
#: py/compile.c
222-
msgid "'async for' or 'async with' outside async function"
218+
msgid "'await' outside function"
223219
msgstr ""
224220

225221
#: py/compile.c
226-
msgid "'await' outside function"
222+
msgid "'await', 'async for' or 'async with' outside async function"
227223
msgstr ""
228224

229225
#: py/compile.c
@@ -1336,10 +1332,6 @@ msgstr ""
13361332
msgid "Pull not used when direction is output."
13371333
msgstr ""
13381334

1339-
#: ports/stm/ref/pulseout-pre-timeralloc.c
1340-
msgid "PulseOut not supported on this chip"
1341-
msgstr ""
1342-
13431335
#: ports/stm/common-hal/os/__init__.c
13441336
msgid "RNG DeInit Error"
13451337
msgstr ""
@@ -1773,7 +1765,7 @@ msgstr ""
17731765
msgid "__new__ arg must be a user-type"
17741766
msgstr ""
17751767

1776-
#: extmod/modubinascii.c extmod/moduhashlib.c
1768+
#: extmod/modubinascii.c extmod/moduhashlib.c py/objarray.c
17771769
msgid "a bytes-like object is required"
17781770
msgstr ""
17791771

py/compile.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,11 +1713,11 @@ STATIC void compile_yield_from(compiler_t *comp) {
17131713
#if MICROPY_PY_ASYNC_AWAIT
17141714
STATIC bool compile_require_async_context(compiler_t *comp, mp_parse_node_struct_t *pns) {
17151715
int scope_flags = comp->scope_cur->scope_flags;
1716-
if(scope_flags & MP_SCOPE_FLAG_GENERATOR) {
1716+
if(scope_flags & MP_SCOPE_FLAG_ASYNC) {
17171717
return true;
17181718
}
17191719
compile_syntax_error(comp, (mp_parse_node_t)pns,
1720-
translate("'async for' or 'async with' outside async function"));
1720+
translate("'await', 'async for' or 'async with' outside async function"));
17211721
return false;
17221722
}
17231723

@@ -2645,6 +2645,7 @@ STATIC void compile_atom_expr_await(compiler_t *comp, mp_parse_node_struct_t *pn
26452645
compile_syntax_error(comp, (mp_parse_node_t)pns, translate("'await' outside function"));
26462646
return;
26472647
}
2648+
compile_require_async_context(comp, pns);
26482649
compile_atom_expr_normal(comp, pns);
26492650
compile_yield_from(comp);
26502651
}

0 commit comments

Comments
 (0)