New submission from Dmitry Kazakov <waul...@gmail.com>: A few of the methods of collections.UserString return objects of type str when one would expect instances of UserString or a subclass. Here's an example for UserString.join:
>>> s = UserString(', ').join(['a', 'b', 'c']); print(repr(s), type(s)) 'a, b, c' <class 'str'> This *looks* like a bug to me, but since I was unable to find similar bug reports, and this behaviour has existed for years, I'm not too sure. Same holds for UserString.format and UserString.format_map, which were added recently (issue 22189): >>> s = UserString('{}').format(1); print(repr(s), type(s)) '1' <class 'str'> At least, this output is inconsistent with %-based formatting: >>> s = UserString('%d') % 1; print(repr(s), type(s)) '1' <class 'collections.UserString'> ---------- components: Library (Lib) messages: 304761 nosy: vaultah priority: normal severity: normal status: open title: Several methods of collections.UserString do not return instances of UserString or its subclasses type: behavior _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31841> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com