Fix SF bug #683467, 'int' ability to generate longs not inherited

When subclassing from an int but not overriding __new__,
long values were not converted properly.  Try to convert
longs into an int.
This commit is contained in:
Neal Norwitz 2003-02-10 02:12:43 +00:00
parent 9caf9c040e
commit de8b94c3e1
3 changed files with 27 additions and 2 deletions

View file

@ -458,12 +458,20 @@ def ints():
class C(int):
def __add__(self, other):
return NotImplemented
vereq(C(5L), 5)
try:
C() + ""
except TypeError:
pass
else:
raise TestFailed, "NotImplemented should have caused TypeError"
import sys
try:
C(sys.maxint+1)
except OverflowError:
pass
else:
raise TestFailed, "should have raised OverflowError"
def longs():
if verbose: print "Testing long operations..."