On Sun, Mar 22, 2020 at 4:20 AM Eric V. Smith <eric@trueblade.com> wrote:
Agreed. I think the PEP should say that a str will be returned (in the
event of a subclass, assuming that's what we decide), but if the
argument is exactly a str, that it may or may not return the original

Yes. Returning self if the class is exactly str is *just* an optimization -- it must not be mandated nor ruled out.

And we *have* to decide that it returns a plain str instance if called on a subclass instance (unless overridden, of course) since the base class (str) won't know the signature of the subclass constructor. That's also why all other str methods return an instance of plain str when called on a subclass instance.

--Guido van Rossum (python.org/~guido)