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 /Modules | |
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 'Modules')
-rw-r--r-- | Modules/_ctypes/callbacks.c | 1 | ||||
-rw-r--r-- | Modules/parsermodule.c | 42 | ||||
-rw-r--r-- | Modules/pyexpat.c | 1 |
3 files changed, 35 insertions, 9 deletions
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c index c8e669a..d5ab43b 100644 --- a/Modules/_ctypes/callbacks.c +++ b/Modules/_ctypes/callbacks.c @@ -51,6 +51,7 @@ void _AddTraceback(char *funcname, char *filename, int lineno) if (!empty_string) goto bad; py_code = PyCode_New( 0, /*int argcount,*/ + 0, /*int kwonlyargcount,*/ 0, /*int nlocals,*/ 0, /*int stacksize,*/ 0, /*int flags,*/ diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c index 74af7fe..39394a5 100644 --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -1105,13 +1105,13 @@ validate_testlist_safe(node *tree) } -/* '*' NAME [',' '**' NAME] | '**' NAME +/* '*' [NAME] (',' NAME ['=' test])* [',' '**' NAME] | '**' NAME */ static int validate_varargslist_trailer(node *tree, int start) { int nch = NCH(tree); - int res = 0; + int res = 0, i; int sym; if (nch <= start) { @@ -1121,15 +1121,40 @@ validate_varargslist_trailer(node *tree, int start) sym = TYPE(CHILD(tree, start)); if (sym == STAR) { /* - * ('*' NAME [',' '**' NAME] + * '*' [NAME] (',' NAME ['=' test])* [',' '**' NAME] | '**' NAME */ if (nch-start == 2) res = validate_name(CHILD(tree, start+1), NULL); - else if (nch-start == 5) + else if (nch-start == 5 && TYPE(CHILD(tree, start+2)) == COMMA) res = (validate_name(CHILD(tree, start+1), NULL) && validate_comma(CHILD(tree, start+2)) && validate_doublestar(CHILD(tree, start+3)) && validate_name(CHILD(tree, start+4), NULL)); + else { + /* skip over [NAME] (',' NAME ['=' test])* */ + i = start + 1; + if (TYPE(CHILD(tree, i)) == NAME) { /* skip over [NAME] */ + i += 1; + } + while (res && i+1 < nch) { /* validate (',' NAME ['=' test])* */ + res = validate_comma(CHILD(tree, i)); + if (TYPE(CHILD(tree, i+1)) == DOUBLESTAR) + break; + res = res && validate_name(CHILD(tree, i+1), NULL); + if (res && i+2 < nch && TYPE(CHILD(tree, i+2)) == EQUAL) { + res = res && (i+3 < nch) + && validate_test(CHILD(tree, i+3)); + i += 4; + } + else { + i += 2; + } + } + /* [',' '**' NAME] */ + if (res && i+1 < nch && TYPE(CHILD(tree, i+1)) == DOUBLESTAR) { + res = validate_name(CHILD(tree, i+2), NULL); + } + } } else if (sym == DOUBLESTAR) { /* @@ -1148,9 +1173,8 @@ validate_varargslist_trailer(node *tree, int start) * * varargslist: * (fpdef ['=' test] ',')* - * ('*' NAME [',' '**' NAME] - * | '**' NAME) - * | fpdef ['=' test] (',' fpdef ['=' test])* [','] + * ('*' [NAME] (',' NAME ['=' test])* [',' '**' NAME] | '**' NAME) + * | fpdef ['=' test] (',' fpdef ['=' test])* [','] * */ static int @@ -1169,7 +1193,7 @@ validate_varargslist(node *tree) sym = TYPE(CHILD(tree, 0)); if (sym == STAR || sym == DOUBLESTAR) /* whole thing matches: - * '*' NAME [',' '**' NAME] | '**' NAME + * '*' [NAME] (',' NAME ['=' test])* [',' '**' NAME] | '**' NAME */ res = validate_varargslist_trailer(tree, 0); else if (sym == fpdef) { @@ -1201,7 +1225,7 @@ validate_varargslist(node *tree) break; } } - /* ... '*' NAME [',' '**' NAME] | '**' NAME + /* .. ('*' [NAME] (',' NAME ['=' test])* [',' '**' NAME] | '**' NAME) * i --^^^ */ if (res) diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index 603beed..87a16ef 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -279,6 +279,7 @@ getcode(enum HandlerTypes slot, char* func_name, int lineno) filename = PyString_FromString(__FILE__); handler_info[slot].tb_code = PyCode_New(0, /* argcount */ + 0, /* kwonlyargcount */ 0, /* nlocals */ 0, /* stacksize */ 0, /* flags */ |