mirror of https://github.com/python/cpython.git
Fix my last change on PyUnicode_Join(): don't process separator if len==1
This commit is contained in:
parent
25a4b29c95
commit
acf47b807f
|
@ -9145,13 +9145,16 @@ PyUnicode_Join(PyObject *separator, PyObject *seq)
|
||||||
|
|
||||||
/* If singleton sequence with an exact Unicode, return that. */
|
/* If singleton sequence with an exact Unicode, return that. */
|
||||||
items = PySequence_Fast_ITEMS(fseq);
|
items = PySequence_Fast_ITEMS(fseq);
|
||||||
if (seqlen == 1 && PyUnicode_CheckExact(items[0])) {
|
if (seqlen == 1) {
|
||||||
|
if (PyUnicode_CheckExact(items[0])) {
|
||||||
res = items[0];
|
res = items[0];
|
||||||
Py_INCREF(res);
|
Py_INCREF(res);
|
||||||
Py_DECREF(fseq);
|
Py_DECREF(fseq);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
sep = NULL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
/* Set up sep and seplen */
|
/* Set up sep and seplen */
|
||||||
if (separator == NULL) {
|
if (separator == NULL) {
|
||||||
/* fall back to a blank space separator */
|
/* fall back to a blank space separator */
|
||||||
|
@ -9177,6 +9180,7 @@ PyUnicode_Join(PyObject *separator, PyObject *seq)
|
||||||
above case of a blank separator */
|
above case of a blank separator */
|
||||||
Py_INCREF(sep);
|
Py_INCREF(sep);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* There are at least two things to join, or else we have a subclass
|
/* There are at least two things to join, or else we have a subclass
|
||||||
* of str in the sequence.
|
* of str in the sequence.
|
||||||
|
|
Loading…
Reference in New Issue