Skip to content

gh-115754: Use Py_GetConstant(Py_CONSTANT_EMPTY_STR) #125583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@ make_Zreplacement(PyObject *object, PyObject *tzinfoarg)
{
PyObject *temp;
PyObject *tzinfo = get_tzinfo_member(object);
PyObject *Zreplacement = PyUnicode_FromStringAndSize(NULL, 0);
PyObject *Zreplacement = Py_GetConstant(Py_CONSTANT_EMPTY_STR);

if (Zreplacement == NULL)
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion Modules/_io/textio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1806,7 +1806,7 @@ textiowrapper_get_decoded_chars(textio *self, Py_ssize_t n)
Py_ssize_t avail;

if (self->decoded_chars == NULL)
return PyUnicode_FromStringAndSize(NULL, 0);
return Py_GetConstant(Py_CONSTANT_EMPTY_STR);

/* decoded_chars is guaranteed to be "ready". */
avail = (PyUnicode_GET_LENGTH(self->decoded_chars)
Expand Down
6 changes: 3 additions & 3 deletions Modules/getpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ getpath_dirname(PyObject *Py_UNUSED(self), PyObject *args)
Py_ssize_t end = PyUnicode_GET_LENGTH(path);
Py_ssize_t pos = PyUnicode_FindChar(path, SEP, 0, end, -1);
if (pos < 0) {
return PyUnicode_FromStringAndSize(NULL, 0);
return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
return PyUnicode_Substring(path, 0, pos);
}
Expand Down Expand Up @@ -258,7 +258,7 @@ getpath_joinpath(PyObject *Py_UNUSED(self), PyObject *args)
}
Py_ssize_t n = PyTuple_GET_SIZE(args);
if (n == 0) {
return PyUnicode_FromStringAndSize(NULL, 0);
return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
/* Convert all parts to wchar and accumulate max final length */
wchar_t **parts = (wchar_t **)PyMem_Malloc(n * sizeof(wchar_t *));
Expand Down Expand Up @@ -302,7 +302,7 @@ getpath_joinpath(PyObject *Py_UNUSED(self), PyObject *args)
PyErr_NoMemory();
return NULL;
}
return PyUnicode_FromStringAndSize(NULL, 0);
return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}

final[0] = '\0';
Expand Down
Loading