From: Mariatta Date: Fri, 26 Jan 2018 17:55:15 +0000 (-0800) Subject: [2.7] bpo-32640: Clarify the behavior of str.join and unicode object (GH-5333) X-Git-Tag: v2.7.15rc1~71 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f5e8f71fe339fe5e47c4d24ac2e5177fa3c02922;p=python [2.7] bpo-32640: Clarify the behavior of str.join and unicode object (GH-5333) In str.join, if any of the iterable contains a Unicode object, str.join will return a Unicode object. A Type error will be raised if iterable contains values other than a string or Unicode object. --- diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index bc7411c809..e16bd77188 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1071,9 +1071,10 @@ string functions based on regular expressions. .. method:: str.join(iterable) Return a string which is the concatenation of the strings in *iterable*. - A :exc:`TypeError` will be raised if there are any non-string values in - *iterable*, including :class:`bytes` objects. The separator between - elements is the string providing this method. + If there is any Unicode object in *iterable*, return a Unicode instead. + A :exc:`TypeError` will be raised if there are any non-string or non Unicode + object values in *iterable*. The separator between elements is the string + providing this method. .. method:: str.ljust(width[, fillchar])