Issue 2440: fix the handling of %n in Python/getargs.c's convertsimple(), extend Objects/abstract.c's PyNumber_Index() to accept PyObjects that have nb_int slots, and update test_getargs2 to test that an exception is thrown when __int__() returns a non-int object.

This commit is contained in:
Trent Nelson 2008-04-10 16:25:37 +00:00
parent 5680d0c5e3
commit e2ae4684a5
3 changed files with 21 additions and 6 deletions

View file

@ -63,6 +63,10 @@ class Int:
def __int__(self):
return 99
class InvalidLongAsString:
def __int__(self):
return 'foobar'
class Unsigned_TestCase(unittest.TestCase):
def test_b(self):
from _testcapi import getargs_b
@ -199,6 +203,7 @@ class Signed_TestCase(unittest.TestCase):
self.failUnlessEqual(42, getargs_n(42))
self.assertRaises(OverflowError, getargs_n, VERY_LARGE)
self.assertRaises(TypeError, getargs_n, InvalidLongAsString())
class LongLong_TestCase(unittest.TestCase):
def test_L(self):