mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
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:
parent
6a39e96ab8
commit
b9a8ca0a6a
22 changed files with 35 additions and 35 deletions
|
@ -196,7 +196,7 @@ list_join(PyObject* list)
|
|||
PyObject* joiner;
|
||||
PyObject* result;
|
||||
|
||||
joiner = PyUnicode_FromStringAndSize("", 0);
|
||||
joiner = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
|
||||
if (!joiner)
|
||||
return NULL;
|
||||
result = PyUnicode_Join(joiner, list);
|
||||
|
@ -1317,7 +1317,7 @@ _elementtree_Element_findtext_impl(ElementObject *self, PyTypeObject *cls,
|
|||
PyObject* text = element_get_text((ElementObject*)item);
|
||||
if (text == Py_None) {
|
||||
Py_DECREF(item);
|
||||
return PyUnicode_New(0, 0);
|
||||
return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
|
||||
}
|
||||
Py_XINCREF(text);
|
||||
Py_DECREF(item);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue