diff options
author | Batuhan Taşkaya <batuhanosmantaskaya@gmail.com> | 2020-04-14 20:21:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-14 20:21:22 (GMT) |
commit | 43aeefa41915e4d3b0e68bbd4268c1c378a72dce (patch) | |
tree | 2a8a26ed6c78aae5a3eea545e1de3893978a6a23 | |
parent | 4c0a31fb08407ba043688ad1c21102dd4cb99146 (diff) | |
download | cpython-43aeefa41915e4d3b0e68bbd4268c1c378a72dce.zip cpython-43aeefa41915e4d3b0e68bbd4268c1c378a72dce.tar.gz cpython-43aeefa41915e4d3b0e68bbd4268c1c378a72dce.tar.bz2 |
bpo-39522: Use _PyUnicodeWriter_WriteStr instead of PyUnicode_AS_DATA (GH-19523)
-rw-r--r-- | Python/ast_unparse.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Python/ast_unparse.c b/Python/ast_unparse.c index c321acf..443e712 100644 --- a/Python/ast_unparse.c +++ b/Python/ast_unparse.c @@ -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); |