summaryrefslogtreecommitdiff
path: root/Python/future.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-12-02 23:15:22 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2016-12-02 23:15:22 +0200
commit43ebbf7db2d3d3297e96693fd91ac8a654631438 (patch)
tree29bd29d34fb300890dd0559befc06f4e0adc61d7 /Python/future.c
parentbf4d9c8ae56c531f020b58c10c99e04ac17a4eff (diff)
parentb9210b0f24ee0ba5861dffbaa42559a409a71a3e (diff)
downloadcpython-43ebbf7db2d3d3297e96693fd91ac8a654631438.tar.gz
Issue #21818: Fixed references to classes that have names matching with module
names.
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++;