Dirk Meyer wrote:
> Duncan Webb wrote:
>> Modified: branches/rel-1/freevo/src/item.py
>> ==============================================================================
>> --- branches/rel-1/freevo/src/item.py (original)
>> +++ branches/rel-1/freevo/src/item.py Mon Jan 8 19:57:43 2007
>> @@ -471,4 +471,4 @@
>> return self.__getitem__(attr)
>> else:
>> r = self.__getitem__(attr)
>> - return Unicode(r)
>> + return Unicode(str(r))
>
> Unicode should use str() if the object is neither str nor
> unicode. This patch shouldn't do anything, except crash if r is
> already unicode.
Thanks dischi, good point.
I have two problems.
1) the Unicode function does convert convert the argument to a string if
it not a string or a unicode string. So I wonder why the type error was
raised.
2) there is no line 488 in src/item.py (missed this because it was the
last line and vim went to the last line)
File "/usr/lib/python2.4/site-packages/freevo/item.py", line 488, in getattr
r = self.__getitem__(attr)
File "/usr/lib/python2.4/site-packages/freevo/directory.py", line 315,
in __getitem__
return self['num_%s_items' % display_type] + self['num_dir_items']
TypeError: cannot concatenate 'str' and 'int' objects
def Unicode(string, encoding=config.encoding):
if string.__class__ == str:
try:
return unicode(string, encoding)
except Exception, e:
try:
return unicode(string, config.LOCALE)
except Exception, e:
try:
return unicode(string, "iso-8859-15")
except Exception, e:
print 'Error: Could not convert %s to unicode' %
repr(string)
print 'tried encoding %s and %s' % (encoding,
config.LOCALE)
print e
elif string.__class__ != unicode:
return unicode(str(string), config.LOCALE)
return string
I have reversed the fix and committed it back.
Duncan
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog