summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-10-25 09:14:52 (GMT)
committerGitHub <noreply@github.com>2024-10-25 09:14:52 (GMT)
commitebcc578dff47b1dcffb634923bedc5361c8f29f6 (patch)
tree0d9ba11a0efeec743ca57fd2ee6cfdc0d1d68d36 /Modules
parentdb96327203b09ada45f2214567f92fe4d837f82a (diff)
downloadcpython-ebcc578dff47b1dcffb634923bedc5361c8f29f6.zip
cpython-ebcc578dff47b1dcffb634923bedc5361c8f29f6.tar.gz
cpython-ebcc578dff47b1dcffb634923bedc5361c8f29f6.tar.bz2
gh-115754: Use Py_GetConstant(Py_CONSTANT_EMPTY_STR) (#125583)
Replace PyUnicode_FromStringAndSize(NULL, 0) with Py_GetConstant(Py_CONSTANT_EMPTY_STR).
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_datetimemodule.c2
-rw-r--r--Modules/_io/textio.c2
-rw-r--r--Modules/getpath.c6
3 files changed, 5 insertions, 5 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index e1bb98f..b110298 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -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;
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index 68d1636..0d851ee 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -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)
diff --git a/Modules/getpath.c b/Modules/getpath.c
index d0128b2..18ddfaf 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -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);
}
@@ -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 *));
@@ -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';