diff options
author | Anthony Baxter <anthonybaxter@gmail.com> | 2004-08-31 10:07:13 (GMT) |
---|---|---|
committer | Anthony Baxter <anthonybaxter@gmail.com> | 2004-08-31 10:07:13 (GMT) |
commit | 1a4ddaecc732c207fa69890db87ac4b47da867b8 (patch) | |
tree | 3c0c9c3086bc1c5ac72554e8ce6a03773cdc8770 /Python/future.c | |
parent | 876032e5700f58cec44a357b6d3174be76b40278 (diff) | |
download | cpython-1a4ddaecc732c207fa69890db87ac4b47da867b8.zip cpython-1a4ddaecc732c207fa69890db87ac4b47da867b8.tar.gz cpython-1a4ddaecc732c207fa69890db87ac4b47da867b8.tar.bz2 |
SF patch #1007189, multi-line imports, for instance:
"from blah import (foo, bar
baz, bongo)"
Diffstat (limited to 'Python/future.c')
-rw-r--r-- | Python/future.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/Python/future.c b/Python/future.c index 377ad9a..20d8dd2 100644 --- a/Python/future.c +++ b/Python/future.c @@ -18,18 +18,18 @@ future_check_features(PyFutureFeatures *ff, node *n, const char *filename) { int i; char *feature; - node *ch; + node *ch, *nn; - REQ(n, import_stmt); /* must by from __future__ import ... */ - - for (i = 3; i < NCH(n); i += 2) { - ch = CHILD(n, i); - if (TYPE(ch) == STAR) { - PyErr_SetString(PyExc_SyntaxError, - FUTURE_IMPORT_STAR); - PyErr_SyntaxLocation(filename, ch->n_lineno); - return -1; - } + REQ(n, import_from); + nn = CHILD(n, 3 + (TYPE(CHILD(n, 3)) == LPAR)); + if (TYPE(nn) == STAR) { + PyErr_SetString(PyExc_SyntaxError, FUTURE_IMPORT_STAR); + PyErr_SyntaxLocation(filename, nn->n_lineno); + return -1; + } + REQ(nn, import_as_names); + for (i = 0; i < NCH(nn); i += 2) { + ch = CHILD(nn, i); REQ(ch, import_as_name); feature = STR(CHILD(ch, 0)); if (strcmp(feature, FUTURE_NESTED_SCOPES) == 0) { @@ -188,7 +188,8 @@ future_parse(PyFutureFeatures *ff, node *n, const char *filename) case import_stmt: { node *name; - if (STR(CHILD(n, 0))[0] != 'f') { /* from */ + n = CHILD(n, 0); + if (TYPE(n) != import_from) { ff->ff_last_lineno = n->n_lineno; return 0; } |