summaryrefslogtreecommitdiffstats
path: root/Objects/stringlib
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 /Objects/stringlib
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 'Objects/stringlib')
-rw-r--r--Objects/stringlib/unicode_format.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/stringlib/unicode_format.h b/Objects/stringlib/unicode_format.h
index 91c71ab..44b269b 100644
--- a/Objects/stringlib/unicode_format.h
+++ b/Objects/stringlib/unicode_format.h
@@ -73,7 +73,7 @@ Py_LOCAL_INLINE(PyObject *)
SubString_new_object_or_empty(SubString *str)
{
if (str->str == NULL) {
- return PyUnicode_New(0, 0);
+ return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
return SubString_new_object(str);
}
@@ -531,7 +531,7 @@ render_field(PyObject *fieldobj, SubString *format_spec, _PyUnicodeWriter *write
format_spec->start,
format_spec->end);
else
- format_spec_object = PyUnicode_New(0, 0);
+ format_spec_object = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
if (format_spec_object == NULL)
goto done;