Message1461

Author pekka.klarck
Recipients
Date 2007-02-15.22:36:34
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
I was trying to find the cause for some of these problems (partly to see how easily I can understand Jython internals) and found the following from /trunk/jython/src/templates/str.expose (revision 3058). 

   41 expose_meth: join o
   42     String result = self.str_join(arg0);
   43     //XXX: do we really need to check self?
   44     if (self instanceof PyUnicode || arg0 instanceof PyUnicode) {
   45         return new PyUnicode(result);
   46     } else {
   47         return new PyString(result);
   48     }

I know next to nothing about these expose files (I've understood the actual Java code is generated from them) but if I got it correctly "arg0 instanceof PyUnicode" checks is the argument given to the join method a unicode object or not. If that's the case then the bug in join is exactly here -- the argument given to it is a sequence and thus never unicode itself. Instead the code should check is any of the items in the sequence of unicode type. The XXX comment can also probably be removed because u''.join([]) should create a unicode object too.

If str.expose is the right place to fix these issues then also replace method ought to get similar checks as join has.

Fixing join and replace still leaves "'%s' % u'x'" issue open.
History
Date User Action Args
2008-02-20 17:17:43adminlinkissue1659819 messages
2008-02-20 17:17:43admincreate