summaryrefslogtreecommitdiff
path: root/Python/future.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/future.c')
-rw-r--r--Python/future.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Python/future.c b/Python/future.c
index 4de801bfc0..9c1f43032a 100644
--- a/Python/future.c
+++ b/Python/future.c
@@ -21,7 +21,7 @@ future_check_features(PyFutureFeatures *ff, stmt_ty s, PyObject *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 = _PyUnicode_AsString(name->name);
+ const char *feature = PyUnicode_AsUTF8(name->name);
if (!feature)
return 0;
if (strcmp(feature, FUTURE_NESTED_SCOPES) == 0) {
@@ -79,7 +79,10 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, PyObject *filename)
i = 0;
first = (stmt_ty)asdl_seq_GET(mod->v.Module.body, i);
- if (first->kind == Expr_kind && first->v.Expr.value->kind == Str_kind)
+ if (first->kind == Expr_kind
+ && (first->v.Expr.value->kind == Str_kind
+ || (first->v.Expr.value->kind == Constant_kind
+ && PyUnicode_CheckExact(first->v.Expr.value->v.Constant.value))))
i++;