summaryrefslogtreecommitdiffstats
path: root/Parser/action_helpers.c
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2023-06-02 11:33:26 (GMT)
committerGitHub <noreply@github.com>2023-06-02 11:33:26 (GMT)
commit41de54378d54f7ffc38f07db4219e80f48c4249e (patch)
tree42b56206d421d532fb2ac1a9cce7a31458ab26c4 /Parser/action_helpers.c
parent4bfa01b9d911ce9358cf1a453bee15554f8e4c07 (diff)
downloadcpython-41de54378d54f7ffc38f07db4219e80f48c4249e.zip
cpython-41de54378d54f7ffc38f07db4219e80f48c4249e.tar.gz
cpython-41de54378d54f7ffc38f07db4219e80f48c4249e.tar.bz2
gh-105194: Fix format specifier escaped characters in f-strings (#105231)
Diffstat (limited to 'Parser/action_helpers.c')
-rw-r--r--Parser/action_helpers.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/Parser/action_helpers.c b/Parser/action_helpers.c
index 2411da2..7786124 100644
--- a/Parser/action_helpers.c
+++ b/Parser/action_helpers.c
@@ -1350,6 +1350,25 @@ _PyPegen_joined_str(Parser *p, Token* a, asdl_expr_seq* raw_expressions, Token*b
p->arena);
}
+expr_ty _PyPegen_decoded_constant_from_token(Parser* p, Token* tok) {
+ Py_ssize_t bsize;
+ char* bstr;
+ if (PyBytes_AsStringAndSize(tok->bytes, &bstr, &bsize) == -1) {
+ return NULL;
+ }
+ PyObject* str = _PyPegen_decode_string(p, 0, bstr, bsize, tok);
+ if (str == NULL) {
+ return NULL;
+ }
+ if (_PyArena_AddPyObject(p->arena, str) < 0) {
+ Py_DECREF(str);
+ return NULL;
+ }
+ return _PyAST_Constant(str, NULL, tok->lineno, tok->col_offset,
+ tok->end_lineno, tok->end_col_offset,
+ p->arena);
+}
+
expr_ty _PyPegen_constant_from_token(Parser* p, Token* tok) {
char* bstr = PyBytes_AsString(tok->bytes);
if (bstr == NULL) {