diff -r 2c45f75a5406 Lib/test/test_int_overflow_jy.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/test_int_overflow_jy.py Mon Aug 04 15:55:42 2014 +1000 @@ -0,0 +1,24 @@ +"""Int overflow tests + +Tests for int overflow on new style classes. +""" +import unittest +import types +from test import test_support + +class IntOverflowTest(unittest.TestCase): + def test_new_class_len_overflow(self): + class X(object): + def __len__(self): + return 2 ** 70 + x = X() + with self.assertRaises(OverflowError) as context: + len(x) + +def test_main(): + test_support.run_unittest(IntTestCase) + +if __name__ == '__main__': + test_main() + + diff -r 2c45f75a5406 src/org/python/core/PyObjectDerived.java --- a/src/org/python/core/PyObjectDerived.java Mon Jul 14 14:19:57 2014 -0600 +++ b/src/org/python/core/PyObjectDerived.java Mon Aug 04 15:55:42 2014 +1000 @@ -834,9 +834,7 @@ PyObject impl=self_type.lookup("__len__"); if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); - if (res instanceof PyInteger) - return((PyInteger)res).getValue(); - throw Py.TypeError("__len__ should return a int"); + return res.asInt(); } return super.__len__(); }