]> granicus.if.org Git - python/commitdiff
[2.7] bpo-32640: Clarify the behavior of str.join and unicode object (GH-5333)
authorMariatta <Mariatta@users.noreply.github.com>
Fri, 26 Jan 2018 17:55:15 +0000 (09:55 -0800)
committerGitHub <noreply@github.com>
Fri, 26 Jan 2018 17:55:15 +0000 (09:55 -0800)
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.

Doc/library/stdtypes.rst

index bc7411c809a7ef4a730f177cbf41fc8d3b0686fa..e16bd77188fa21007c4403a18cf8111c391dcd41 100644 (file)
@@ -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])