diff options
Diffstat (limited to 'Python/future.c')
-rw-r--r-- | Python/future.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/Python/future.c b/Python/future.c index 515dcd9dc6..d24ae416ff 100644 --- a/Python/future.c +++ b/Python/future.c @@ -4,7 +4,6 @@ #include "token.h" #include "graminit.h" #include "code.h" -#include "compile.h" #include "symtable.h" #define UNDEFINED_FUTURE_FEATURE "future feature %.100s is not defined" @@ -44,12 +43,12 @@ future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename) } else if (strcmp(feature, "braces") == 0) { PyErr_SetString(PyExc_SyntaxError, "not a chance"); - PyErr_SyntaxLocation(filename, s->lineno); + PyErr_SyntaxLocationEx(filename, s->lineno, s->col_offset); return 0; } else { PyErr_Format(PyExc_SyntaxError, UNDEFINED_FUTURE_FEATURE, feature); - PyErr_SyntaxLocation(filename, s->lineno); + PyErr_SyntaxLocationEx(filename, s->lineno, s->col_offset); return 0; } } @@ -61,13 +60,6 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename) { int i, found_docstring = 0, done = 0, prev_line = 0; - static PyObject *future; - if (!future) { - future = PyUnicode_InternFromString("__future__"); - if (!future) - return 0; - } - if (!(mod->kind == Module_kind || mod->kind == Interactive_kind)) return 1; @@ -94,12 +86,13 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename) */ if (s->kind == ImportFrom_kind) { - if (s->v.ImportFrom.module == future) { + identifier modname = s->v.ImportFrom.module; + if (modname && + !PyUnicode_CompareWithASCIIString(modname, "__future__")) { if (done) { PyErr_SetString(PyExc_SyntaxError, ERR_LATE_FUTURE); - PyErr_SyntaxLocation(filename, - s->lineno); + PyErr_SyntaxLocationEx(filename, s->lineno, s->col_offset); return 0; } if (!future_check_features(ff, s, filename)) |