From 4e7340e82b7ee295358403697a75133a5aec8a34 Mon Sep 17 00:00:00 2001 From: David Fisher Date: Wed, 5 Apr 2017 15:21:37 -0700 Subject: [PATCH] [ast27] Fix PyBytes_AS_STRING being called on unicode objects --- ast27/Python/ast.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ast27/Python/ast.c b/ast27/Python/ast.c index 5340d332..82a31d96 100644 --- a/ast27/Python/ast.c +++ b/ast27/Python/ast.c @@ -456,7 +456,7 @@ set_context(struct compiling *c, expr_ty e, expr_context_ty ctx, const node *n) switch (e->kind) { case Attribute_kind: if (ctx == Store && !forbidden_check(c, n, - PyBytes_AS_STRING(e->v.Attribute.attr))) + (char *)PyUnicode_AsUTF8String(e->v.Attribute.attr))) return 0; e->v.Attribute.ctx = ctx; break; @@ -465,7 +465,7 @@ set_context(struct compiling *c, expr_ty e, expr_context_ty ctx, const node *n) break; case Name_kind: if (ctx == Store && !forbidden_check(c, n, - PyBytes_AS_STRING(e->v.Name.id))) + (char *)PyUnicode_AsUTF8String(e->v.Name.id))) return 0; e->v.Name.ctx = ctx; break; @@ -2203,7 +2203,7 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func) return NULL; } key = e->v.Name.id; - if (!forbidden_check(c, CHILD(ch, 0), PyBytes_AS_STRING(key))) + if (!forbidden_check(c, CHILD(ch, 0), (char *)PyUnicode_AsUTF8String(key))) return NULL; for (k = 0; k < nkeywords; k++) { tmp = _PyUnicode_AsString(