summaryrefslogtreecommitdiffstats
path: root/Python/Python-tokenize.c
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 /Python/Python-tokenize.c
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 'Python/Python-tokenize.c')
-rw-r--r--Python/Python-tokenize.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Python/Python-tokenize.c b/Python/Python-tokenize.c
index 34b4445..50ce83d 100644
--- a/Python/Python-tokenize.c
+++ b/Python/Python-tokenize.c
@@ -263,7 +263,7 @@ tokenizeriter_next(tokenizeriterobject *it)
}
PyObject *str = NULL;
if (token.start == NULL || token.end == NULL) {
- str = PyUnicode_FromString("");
+ str = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
else {
str = PyUnicode_FromStringAndSize(token.start, token.end - token.start);
@@ -281,7 +281,7 @@ tokenizeriter_next(tokenizeriterobject *it)
PyObject* line = NULL;
int line_changed = 1;
if (it->tok->tok_extra_tokens && is_trailing_token) {
- line = PyUnicode_FromString("");
+ line = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
} else {
Py_ssize_t size = it->tok->inp - line_start;
if (size >= 1 && it->tok->implicit_newline) {
@@ -326,7 +326,7 @@ tokenizeriter_next(tokenizeriterobject *it)
else if (type == NL) {
if (it->tok->implicit_newline) {
Py_DECREF(str);
- str = PyUnicode_FromString("");
+ str = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
}