[issue2723] Truncate __len__() at sys.maxsize

Rodrigo Bernardo Pimentel report at bugs.python.org
Sat May 10 21:46:51 CEST 2008


Rodrigo Bernardo Pimentel <rbp at isnomore.net> added the comment:

I think returning sys.{maxint,maxsize} in this case is a plain lie.
That's not practicality, that's giving back false information.

Barring drastic language changes (such as having objects representing
"infinity" or "greater than" - which, of course, won't happen), I think
the current behaviour of raising an exception is the correct one. But,
although I think OverflowError is good enough, the current exception
message is a bit cryptic, especially for anyone who doesn't know C:

"""OverflowError: Python int too large to convert to C ssize_t"""

I've attached a simple patch (modified from Alexander's) to raise:

"""OverflowError: Length too large"""

(I thought about "Object too large", but our problem is actually that
the *length* itself is too large)

----------
nosy: +rbp
Added file: http://bugs.python.org/file10270/len_message.patch

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2723>
__________________________________


More information about the Python-bugs-list mailing list