Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
217 changes: 215 additions & 2 deletions locale/ID.po

Large diffs are not rendered by default.

217 changes: 215 additions & 2 deletions locale/circuitpython.pot

Large diffs are not rendered by default.

217 changes: 215 additions & 2 deletions locale/de_DE.po

Large diffs are not rendered by default.

217 changes: 215 additions & 2 deletions locale/en_US.po

Large diffs are not rendered by default.

217 changes: 215 additions & 2 deletions locale/en_x_pirate.po

Large diffs are not rendered by default.

217 changes: 215 additions & 2 deletions locale/es.po

Large diffs are not rendered by default.

217 changes: 215 additions & 2 deletions locale/fil.po

Large diffs are not rendered by default.

217 changes: 215 additions & 2 deletions locale/fr.po

Large diffs are not rendered by default.

217 changes: 215 additions & 2 deletions locale/it_IT.po

Large diffs are not rendered by default.

217 changes: 215 additions & 2 deletions locale/ko.po

Large diffs are not rendered by default.

217 changes: 215 additions & 2 deletions locale/pl.po

Large diffs are not rendered by default.

217 changes: 215 additions & 2 deletions locale/pt_BR.po

Large diffs are not rendered by default.

217 changes: 215 additions & 2 deletions locale/zh_Latn_pinyin.po

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions py/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1711,6 +1711,16 @@ STATIC void compile_yield_from(compiler_t *comp) {
}

#if MICROPY_PY_ASYNC_AWAIT
STATIC bool compile_require_async_context(compiler_t *comp, mp_parse_node_struct_t *pns) {
int scope_flags = comp->scope_cur->scope_flags;
if(scope_flags & MP_SCOPE_FLAG_GENERATOR) {
return true;
}
compile_syntax_error(comp, (mp_parse_node_t)pns,
translate("'async for' or 'async with' outside async function"));
return false;
}

STATIC void compile_await_object_method(compiler_t *comp, qstr method) {
EMIT_ARG(load_method, method, false);
EMIT_ARG(call_method, 0, 0, 0);
Expand All @@ -1720,6 +1730,10 @@ STATIC void compile_await_object_method(compiler_t *comp, qstr method) {
STATIC void compile_async_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
// comp->break_label |= MP_EMIT_BREAK_FROM_FOR;

if(!compile_require_async_context(comp, pns)) {
return;
}

qstr context = MP_PARSE_NODE_LEAF_ARG(pns->nodes[1]);
uint while_else_label = comp_next_label(comp);
uint try_exception_label = comp_next_label(comp);
Expand Down Expand Up @@ -1857,6 +1871,9 @@ STATIC void compile_async_with_stmt_helper(compiler_t *comp, int n, mp_parse_nod
}

STATIC void compile_async_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
if(!compile_require_async_context(comp, pns)) {
return;
}
// get the nodes for the pre-bit of the with (the a as b, c as d, ... bit)
mp_parse_node_t *nodes;
int n = mp_parse_node_extract_list(&pns->nodes[0], PN_with_stmt_list, &nodes);
Expand Down
3 changes: 3 additions & 0 deletions py/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@ STATIC void push_result_token(parser_t *parser, uint8_t rule_id) {
mp_parse_node_t pn;
mp_lexer_t *lex = parser->lexer;
if (lex->tok_kind == MP_TOKEN_NAME) {
if(lex->vstr.len >= (1 << (8 * MICROPY_QSTR_BYTES_IN_LEN))) {
mp_raise_msg(&mp_type_SyntaxError, translate("Name too long"));
}
qstr id = qstr_from_strn(lex->vstr.buf, lex->vstr.len);
#if MICROPY_COMP_CONST
// if name is a standalone identifier, look it up in the table of dynamic constants
Expand Down