__getslice__ passed INT_MAX rather than sys.maxint for missing endpoint?

Dave Huang khym at azeotrope.org
Sat Mar 26 09:29:46 CET 2005


Hi, I don't actually know Python; I'm just trying to debug a problem
I encounted in another program, so apologies if this has been
covered before. I did do some Google searches though, and didn't
find anything that specifically addressed this :)

According to the documentation at
<http://docs.python.org/ref/sequence-methods.html>, __getslice__
is passed sys.maxint for a missing endpoint (foo[i:]). However, as
far as I can tell, it's actually passing INT_MAX. I'm running Python
2.4 on an Alpha running NetBSD 2.0, an LP64 platform, so the two
aren't the same. INT_MAX is 2^32-1, whereas sys.maxint is LONG_MAX:
2^64-1.

So, am I misunderstanding things, or is this a doc bug, or a code bug?

FWIW, the problem I encountered was some code that did something like:
    def __getslice__(self, a, b):
        if b == maxint:
            b = self.length  # this never got executed, causing problems
-- 
Name: Dave Huang         |  Mammal, mammal / their names are called /
INet: khym at azeotrope.org |  they raise a paw / the bat, the cat /
FurryMUCK: Dahan         |  dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 29 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++



More information about the Python-list mailing list