summaryrefslogtreecommitdiff
path: root/Python/future.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/future.c')
-rw-r--r--Python/future.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/Python/future.c b/Python/future.c
index 0e68845981..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"
@@ -22,7 +21,7 @@ future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename)
names = s->v.ImportFrom.names;
for (i = 0; i < asdl_seq_LEN(names); i++) {
alias_ty name = (alias_ty)asdl_seq_GET(names, i);
- const char *feature = PyString_AsString(name->name);
+ const char *feature = _PyUnicode_AsString(name->name);
if (!feature)
return 0;
if (strcmp(feature, FUTURE_NESTED_SCOPES) == 0) {
@@ -30,24 +29,26 @@ future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename)
} else if (strcmp(feature, FUTURE_GENERATORS) == 0) {
continue;
} else if (strcmp(feature, FUTURE_DIVISION) == 0) {
- ff->ff_features |= CO_FUTURE_DIVISION;
+ continue;
} else if (strcmp(feature, FUTURE_ABSOLUTE_IMPORT) == 0) {
- ff->ff_features |= CO_FUTURE_ABSOLUTE_IMPORT;
+ continue;
} else if (strcmp(feature, FUTURE_WITH_STATEMENT) == 0) {
- ff->ff_features |= CO_FUTURE_WITH_STATEMENT;
+ continue;
} else if (strcmp(feature, FUTURE_PRINT_FUNCTION) == 0) {
- ff->ff_features |= CO_FUTURE_PRINT_FUNCTION;
+ continue;
} else if (strcmp(feature, FUTURE_UNICODE_LITERALS) == 0) {
- ff->ff_features |= CO_FUTURE_UNICODE_LITERALS;
+ continue;
+ } else if (strcmp(feature, FUTURE_BARRY_AS_BDFL) == 0) {
+ ff->ff_features |= CO_FUTURE_BARRY_AS_BDFL;
} 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;
}
}
@@ -86,13 +87,12 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename)
if (s->kind == ImportFrom_kind) {
identifier modname = s->v.ImportFrom.module;
- if (modname && PyString_GET_SIZE(modname) == 10 &&
- !strcmp(PyString_AS_STRING(modname), "__future__")) {
+ 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))