Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 43aeefa

Browse files
authored
bpo-39522: Use _PyUnicodeWriter_WriteStr instead of PyUnicode_AS_DATA (GH-19523)
1 parent 4c0a31f commit 43aeefa

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Python/ast_unparse.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,8 +875,10 @@ append_ast_expr(_PyUnicodeWriter *writer, expr_ty e, int level)
875875
if (e->v.Constant.value == Py_Ellipsis) {
876876
APPEND_STR_FINISH("...");
877877
}
878-
APPEND_STR_IF(e->v.Constant.kind != NULL,
879-
PyUnicode_AS_DATA(e->v.Constant.kind));
878+
if (e->v.Constant.kind != NULL
879+
&& -1 == _PyUnicodeWriter_WriteStr(writer, e->v.Constant.kind)) {
880+
return -1;
881+
}
880882
return append_ast_constant(writer, e->v.Constant.value);
881883
case JoinedStr_kind:
882884
return append_joinedstr(writer, e, false);

0 commit comments

Comments
 (0)