bpo-39522: Use _PyUnicodeWriter_WriteStr instead of PyUnicode_AS_DATA (GH-19523)

This commit is contained in:
Batuhan Taşkaya 2020-04-14 23:21:22 +03:00 committed by GitHub
parent 4c0a31fb08
commit 43aeefa419
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -875,8 +875,10 @@ append_ast_expr(_PyUnicodeWriter *writer, expr_ty e, int level)
if (e->v.Constant.value == Py_Ellipsis) {
APPEND_STR_FINISH("...");
}
APPEND_STR_IF(e->v.Constant.kind != NULL,
PyUnicode_AS_DATA(e->v.Constant.kind));
if (e->v.Constant.kind != NULL
&& -1 == _PyUnicodeWriter_WriteStr(writer, e->v.Constant.kind)) {
return -1;
}
return append_ast_constant(writer, e->v.Constant.value);
case JoinedStr_kind:
return append_joinedstr(writer, e, false);