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).
This commit is contained in:
Victor Stinner 2024-10-09 17:15:23 +02:00 committed by GitHub
parent 6a39e96ab8
commit b9a8ca0a6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 35 additions and 35 deletions

View file

@ -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;