mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
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:
parent
9caf9c040e
commit
de8b94c3e1
3 changed files with 27 additions and 2 deletions
|
@ -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..."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue