New submission from Dennis Sweeney <sweeney.dennis...@gmail.com>:
It seems that `.join` methods typically return the type of the separator on which they are called: >>> bytearray(b" ").join([b"a", b"b"]) bytearray(b'a b') >>> b" ".join([bytearray(b"a"), bytearray(b"b")]) b'a b' This is broken in UserString.join: >>> from collections import UserString as US >>> x = US(" ").join(["a", "b"]) >>> type(x) <class 'str'> Furthermore, this method cannot even accept UserStrings from the iterable: >>> US(" ").join([US("a"), US("b")]) Traceback (most recent call last): ... TypeError: sequence item 0: expected str instance, UserString found. I can submit a PR to fix this. ---------- components: Library (Lib) messages: 363995 nosy: Dennis Sweeney priority: normal severity: normal status: open title: UserString.join should return UserString type: behavior versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39944> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com