diff options
author | Victor Stinner <vstinner@python.org> | 2024-10-09 15:15:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-09 15:15:23 (GMT) |
commit | b9a8ca0a6aa9251cb798f34f0c9d2cc95107eec6 (patch) | |
tree | 570ffb9eae19501a3a173fab2dbf56490d1f83db /Objects/exceptions.c | |
parent | 6a39e96ab8ebc1144f713988ac6fe439e4476488 (diff) | |
download | cpython-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/exceptions.c')
-rw-r--r-- | Objects/exceptions.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index c685481..6fbe0f1 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -154,7 +154,7 @@ BaseException_str(PyBaseExceptionObject *self) { switch (PyTuple_GET_SIZE(self->args)) { case 0: - return PyUnicode_FromString(""); + return Py_GetConstant(Py_CONSTANT_EMPTY_STR); case 1: return PyObject_Str(PyTuple_GET_ITEM(self->args, 0)); default: @@ -3001,7 +3001,7 @@ UnicodeEncodeError_str(PyObject *self) if (exc->object == NULL) { /* Not properly initialized. */ - return PyUnicode_FromString(""); + return Py_GetConstant(Py_CONSTANT_EMPTY_STR); } /* Get reason and encoding as strings, which they might not be if @@ -3123,7 +3123,7 @@ UnicodeDecodeError_str(PyObject *self) if (exc->object == NULL) { /* Not properly initialized. */ - return PyUnicode_FromString(""); + return Py_GetConstant(Py_CONSTANT_EMPTY_STR); } /* Get reason and encoding as strings, which they might not be if @@ -3224,7 +3224,7 @@ UnicodeTranslateError_str(PyObject *self) if (exc->object == NULL) { /* Not properly initialized. */ - return PyUnicode_FromString(""); + return Py_GetConstant(Py_CONSTANT_EMPTY_STR); } /* Get reason as a string, which it might not be if it's been |