[Python-Dev] issues with int/long on 64bit platforms - eg stringobject (PR#306)

Guido van Rossum guido@python.org
Wed, 26 Apr 2000 14:51:56 -0400


> Guido van Rossum wrote:
> > 
> > The email below is a serious bug report.  A quick analysis shows that
> > UserString.count() calls the count() method on a string object, which
> > calls PyArg_ParseTuple() with the format string "O|ii".  The 'i'
> > format code truncates integers.  It probably should raise an overflow
> > exception instead.  But that would still cause the test to fail --
> > just in a different way (more explicit).  Then the string methods
> > should be fixed to use long ints instead -- and then something else
> > would probably break...
> 
> All uses in stringobject.c and unicodeobject.c use INT_MAX
> together with integers, so there's no problem on that side
> of the fence ;-)
> 
> Since strings and Unicode objects use integers to describe the
> length of the object (as well as most if not all other
> builtin sequence types), the correct default value should
> thus be something like sys.maxlen which then gets set to
> INT_MAX.
>  
> I'd suggest adding sys.maxlen and the modifying UserString.py,
> re.py and sre_parse.py accordingly.

Hm, I'm not so sure.  It would be much better if passing sys.maxint
would just WORK...  Since that's what people have been doing so far.

--Guido van Rossum (home page: http://www.python.org/~guido/)