Hi all,

the docstring of util.to_unicode() says clearly that it converts an
"encoded string to unicode string". Unfortunately when the function is
called with anything else than an instance of basestring (str,
unicode) the input value is returned without any type conversion. It's
actually not what I'd expected. What I'd expected is either that the
function raises an exception if the input value isn't an instance of
basestring or that the function tries to convert the input value into
an unicode. For example, when calling "to_unicode(1L)" I would expect
that the return value is u"1" but not 1L.

Are there any concerns to add some simple type conversion. IMO something like

if not isinstance(value, basestring):
  value = unicode(value)
if isinstanve(value, str):
  [...conversion as usual...]
return value

is better than returning value without even trying to convert it to an
unicode as the function's name suggests.

Andi

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to