[Python-checkins] gh-90699: Use _Py_STR(empty) instead of PyUnicode_New(0, 0) for BUILD_STRING (GH-91476)

corona10 webhook-mailer at python.org
Fri Apr 15 10:21:43 EDT 2022


https://github.com/python/cpython/commit/72965981d1128b3923dad5e850c8cff626ae4dc7
commit: 72965981d1128b3923dad5e850c8cff626ae4dc7
branch: main
author: Dennis Sweeney <36520290+sweeneyde at users.noreply.github.com>
committer: corona10 <donghee.na92 at gmail.com>
date: 2022-04-15T23:21:35+09:00
summary:

gh-90699: Use _Py_STR(empty) instead of PyUnicode_New(0, 0) for BUILD_STRING (GH-91476)

files:
M Python/ceval.c

diff --git a/Python/ceval.c b/Python/ceval.c
index b46b1ef842939..7891547ffc687 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -3152,12 +3152,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
 
         TARGET(BUILD_STRING) {
             PyObject *str;
-            PyObject *empty = PyUnicode_New(0, 0);
-            if (empty == NULL) {
-                goto error;
-            }
-            str = _PyUnicode_JoinArray(empty, stack_pointer - oparg, oparg);
-            Py_DECREF(empty);
+            str = _PyUnicode_JoinArray(&_Py_STR(empty),
+                                       stack_pointer - oparg, oparg);
             if (str == NULL)
                 goto error;
             while (--oparg >= 0) {



More information about the Python-checkins mailing list