[Python-Dev] __str__ and unicode
Barry Warsaw
barry at python.org
Wed Dec 6 14:09:52 CET 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Dec 6, 2006, at 7:07 AM, Nick Coghlan wrote:
> M.-A. Lemburg wrote:
>> On 2006-12-06 10:26, Fredrik Lundh wrote:
>>> From what I can tell, __str__ may return a Unicode object, but
>>> only if can be converted to an 8-bit string using the default
>>> encoding. Is this
>>> on purpose or by accident? Do we have a plan for improving the
>>> situation
>>> in future 2.X releases ?
>
> It has worked that way since at Python least 2.4 (I just tried
> returning
> unicode from __str__ in 2.4.1 and it worked fine). That's the
> oldest version I
> have handy, so I don't know if it was possible in earlier versions.
I don't have anything older than 2.4 laying around either, but IIRC
in 2.3 unicode() did not call __unicode__().
- -Barry
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
iQCVAwUBRXbBIHEjvBPtnXfVAQJC6AQAhPDrd451PYhQHTuFZqFX7oJpuadEONxb
UaBEpWs6yzJjLAxC2tfRVT8vOc1bTmF3Wzf1y5HZsXcbklOFm3USl0YJ8206oDBN
2MGGf2e/JuC5oajo5RJqQ/oqaLDSHb8cD6GP2y/+FFaAhwDnlgnOlV0TxAggKv4K
a9nCnFRwJ8c=
=+mj8
-----END PGP SIGNATURE-----
More information about the Python-Dev
mailing list