diff options
author | Guido van Rossum <guido@python.org> | 2006-10-27 23:31:49 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2006-10-27 23:31:49 (GMT) |
commit | 4f72a78684bbfcdc43ceeabb240ceee54706c4b0 (patch) | |
tree | 743c27c5125dcef580cffe77395fe97bedf40d5f /Python/symtable.c | |
parent | fc2a0a8e3cb1d40fd965576060c28c8bd2ea1ad5 (diff) | |
download | cpython-4f72a78684bbfcdc43ceeabb240ceee54706c4b0.zip cpython-4f72a78684bbfcdc43ceeabb240ceee54706c4b0.tar.gz cpython-4f72a78684bbfcdc43ceeabb240ceee54706c4b0.tar.bz2 |
Jiwon Seo's PEP 3102 implementation.
See SF#1549670.
The compiler package has not yet been updated.
Diffstat (limited to 'Python/symtable.c')
-rw-r--r-- | Python/symtable.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Python/symtable.c b/Python/symtable.c index 8f19e0b..b0ebed4 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -893,6 +893,17 @@ error: } \ } +#define VISIT_KWONLYDEFAULTS(ST, KW_DEFAULTS) { \ + int i = 0; \ + asdl_seq *seq = (KW_DEFAULTS); /* avoid variable capture */ \ + for (i = 0; i < asdl_seq_LEN(seq); i++) { \ + expr_ty elt = (expr_ty)asdl_seq_GET(seq, i); \ + if (!elt) continue; /* can be NULL */ \ + if (!symtable_visit_expr((ST), elt)) \ + return 0; \ + } \ +} + static int symtable_new_tmpname(struct symtable *st) { @@ -910,6 +921,8 @@ symtable_new_tmpname(struct symtable *st) return 1; } + + static int symtable_visit_stmt(struct symtable *st, stmt_ty s) { @@ -919,6 +932,9 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) return 0; if (s->v.FunctionDef.args->defaults) VISIT_SEQ(st, expr, s->v.FunctionDef.args->defaults); + if (s->v.FunctionDef.args->kw_defaults) + VISIT_KWONLYDEFAULTS(st, + s->v.FunctionDef.args->kw_defaults); if (s->v.FunctionDef.decorators) VISIT_SEQ(st, expr, s->v.FunctionDef.decorators); if (!symtable_enter_block(st, s->v.FunctionDef.name, @@ -1262,6 +1278,8 @@ symtable_visit_arguments(struct symtable *st, arguments_ty a) */ if (a->args && !symtable_visit_params(st, a->args, 1)) return 0; + if (a->kwonlyargs && !symtable_visit_params(st, a->kwonlyargs, 1)) + return 0; if (a->vararg) { if (!symtable_add_def(st, a->vararg, DEF_PARAM)) return 0; |