Malthe Borch wrote:
> 2008/10/26 Hanno Schlichting <[EMAIL PROTECTED]>:
>> Didn't we decide to drop support for non-unicode string insertion
>> already? I was under the impression that we shouldn't deal with encoding
>> conversions at all inside the machinery. zope.tal and friends have a
>> clear Unicode-only policy as well.
> There is the odd exception of int; it really does make sense to
> support it natively (in my view).

Of course.

>> should be enough, shouldn't it? Feel free to experiment with using
>> __unicode__ instead, but I have a feeling that checking for the
>> attribute existence, checking if it is a callable and calling it, is
>> more expensive.
> 1. isinstance unicode
> 2. isinstance str (we currently do support this, but maybe shouldn't)
> 3. getattr __unicode__
> 4. coerce to str/unicode

Hhm, what happens if we always do:


Here's my little experiment:

>>> unicode(1)

>>> unicode(u'foo')

>>> class A(object):
...   def __unicode__(self):
...     return u'unicode'
...   def __str__(self):
...     return 'string'
>>> a = A()

>>> a
<__main__.A object at 0x52230>

>>> unicode(a)

That should have next to no performance impact and should work in all
cases (except byte-strings).


You received this message because you are subscribed to the Google Groups 
"" group.
To post to this group, send email to
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at

Reply via email to