summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-10-09 15:15:23 (GMT)
committerGitHub <noreply@github.com>2024-10-09 15:15:23 (GMT)
commitb9a8ca0a6aa9251cb798f34f0c9d2cc95107eec6 (patch)
tree570ffb9eae19501a3a173fab2dbf56490d1f83db /Parser
parent6a39e96ab8ebc1144f713988ac6fe439e4476488 (diff)
downloadcpython-b9a8ca0a6aa9251cb798f34f0c9d2cc95107eec6.zip
cpython-b9a8ca0a6aa9251cb798f34f0c9d2cc95107eec6.tar.gz
cpython-b9a8ca0a6aa9251cb798f34f0c9d2cc95107eec6.tar.bz2
gh-115754: Use Py_GetConstant(Py_CONSTANT_EMPTY_STR) (#125194)
Replace PyUnicode_New(0, 0), PyUnicode_FromString("") and PyUnicode_FromStringAndSize("", 0) with Py_GetConstant(Py_CONSTANT_EMPTY_STR).
Diffstat (limited to 'Parser')
-rw-r--r--Parser/pegen_errors.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Parser/pegen_errors.c b/Parser/pegen_errors.c
index e94a492..6146f69 100644
--- a/Parser/pegen_errors.c
+++ b/Parser/pegen_errors.c
@@ -276,7 +276,7 @@ get_error_line_from_tokenizer_buffers(Parser *p, Py_ssize_t lineno)
assert(p->tok->fp_interactive);
// We can reach this point if the tokenizer buffers for interactive source have not been
// initialized because we failed to decode the original source with the given locale.
- return PyUnicode_FromStringAndSize("", 0);
+ return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
Py_ssize_t relative_lineno = p->starting_lineno ? lineno - p->starting_lineno + 1 : lineno;
@@ -359,7 +359,7 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype,
error_line = get_error_line_from_tokenizer_buffers(p, lineno);
}
else {
- error_line = PyUnicode_FromStringAndSize("", 0);
+ error_line = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
if (!error_line) {
goto error;