Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5c2fab6

Browse files
committed
Simplify %U handling by using Py_UNICODE_COPY.
1 parent 1d0476b commit 5c2fab6

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

Objects/unicodeobject.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -690,11 +690,9 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
690690
case 'U':
691691
{
692692
PyObject *obj = va_arg(vargs, PyObject *);
693-
Py_UNICODE *ucopy = PyUnicode_AS_UNICODE(obj);
694-
Py_ssize_t usize = PyUnicode_GET_SIZE(obj);
695-
Py_ssize_t upos;
696-
for (upos = 0; upos<usize;)
697-
*s++ = ucopy[upos++];
693+
Py_ssize_t size = PyUnicode_GET_SIZE(obj);
694+
Py_UNICODE_COPY(s, PyUnicode_AS_UNICODE(obj), size);
695+
s += size;
698696
break;
699697
}
700698
case 'S':

0 commit comments

Comments
 (0)