[Python-Dev] Revised PEP 349: Allow str() to return unicode strings
paragate at gmx.net
Tue Aug 23 17:45:27 CEST 2005
i have to revise my last posting -- exporting the new ``str``
pure-python implementation breaks -- of course! -- as soon
as ``isinstance(x,str)`` [sic] is used. right now it breaks
because you can't have a function as the second argument of
``isinstance()``, but even if that could be avoided by canny
programming, the fact remains that any object derived from
e.g. a string literal will still be constructed from the
underlying implementation and can't therefore be an instance
of the old ``str``. also, ``str.__bases__`` is not extendable
(it's a tuple) and not replaceable (it's a built-in), so there
seems to be no way to get near a truly working solution except
with C-level patches.
On Tue, 23 Aug 2005 17:21:57 +0200, Neil Schemenauer <nas at arctrix.com>
> I don't think isinstance() would be okay. That test is meant as an
> optimization to avoid calling __str__ on str and unicode instances.
> Subclasses should still have their __str__ method called otherwise
> they cannot override it.
makes perfect sense, i'll change the line back.
More information about the Python-Dev