Skip to content
This repository was archived by the owner on Jul 5, 2023. It is now read-only.

Commit 4d4bb85

Browse files
committed
[2.7] Fix PyBytes_AS_STRING being called on unicode objects (#37)
1 parent 1c66c90 commit 4d4bb85

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ast27/Python/ast.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ set_context(struct compiling *c, expr_ty e, expr_context_ty ctx, const node *n)
456456
switch (e->kind) {
457457
case Attribute_kind:
458458
if (ctx == Store && !forbidden_check(c, n,
459-
PyBytes_AS_STRING(e->v.Attribute.attr)))
459+
(char *)PyUnicode_AsUTF8String(e->v.Attribute.attr)))
460460
return 0;
461461
e->v.Attribute.ctx = ctx;
462462
break;
@@ -465,7 +465,7 @@ set_context(struct compiling *c, expr_ty e, expr_context_ty ctx, const node *n)
465465
break;
466466
case Name_kind:
467467
if (ctx == Store && !forbidden_check(c, n,
468-
PyBytes_AS_STRING(e->v.Name.id)))
468+
(char *)PyUnicode_AsUTF8String(e->v.Name.id)))
469469
return 0;
470470
e->v.Name.ctx = ctx;
471471
break;
@@ -2203,7 +2203,7 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func)
22032203
return NULL;
22042204
}
22052205
key = e->v.Name.id;
2206-
if (!forbidden_check(c, CHILD(ch, 0), PyBytes_AS_STRING(key)))
2206+
if (!forbidden_check(c, CHILD(ch, 0), (char *)PyUnicode_AsUTF8String(key)))
22072207
return NULL;
22082208
for (k = 0; k < nkeywords; k++) {
22092209
tmp = _PyUnicode_AsString(

0 commit comments

Comments
 (0)