[pylucene-dev] Bug/JCC: NumberTools.longToString

Andi Vajda vajda at osafoundation.org
Thu Nov 15 16:49:52 PST 2007


On Thu, 15 Nov 2007, Pete wrote:

> NumberTools.longToString throws a type error on a plain int.
>
> In [3]: NumberTools.longToString(36)
> ---------------------------------------------------------------------------
> <class 'lucene.InvalidArgsError'>         Traceback (most recent call last)
>
> /home/pfein/<ipython console> in <module>()
>
> <class 'lucene.InvalidArgsError'>: (<type 'type'>, 'longToString', 36)
>
> In [4]: NumberTools.longToString(long(36))
> Out[4]: u'00000000000010'

Yes, that's the intent.

I could make the argument parsing more leniant but this comes with two 
problems:

   - it makes it ambiguous: if there were two java methods called
     longToString(), one taking a long and one taking an int, making the long
     one accept int would cause the wrong method to be called if long is
     checked before int.
     Sure, I could, in some cases, determine the right order for checking
     overloads (check int before long since long is wider) but this gets
     pretty complicated.

   - it makes things slower by trying out more things than necessary

If you want to call longToString(36), use longToString(36L) and all is good.

Andi..


More information about the pylucene-dev mailing list