[Python-checkins] [2.7] bpo-32640: Clarify the behavior of str.join and unicode object (GH-5333)

Mariatta webhook-mailer at python.org
Fri Jan 26 12:55:18 EST 2018


https://github.com/python/cpython/commit/f5e8f71fe339fe5e47c4d24ac2e5177fa3c02922
commit: f5e8f71fe339fe5e47c4d24ac2e5177fa3c02922
branch: 2.7
author: Mariatta <Mariatta at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-01-26T09:55:15-08:00
summary:

[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.

files:
M Doc/library/stdtypes.rst

diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index bc7411c809a..e16bd77188f 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])



More information about the Python-checkins mailing list