mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
It turned out not so difficult to support old-style numbers (those
without the Py_TPFLAGS_CHECKTYPES flag) in the wrappers. This required a few changes in test_descr.py to cope with the fact that the complex type has __int__, __long__ and __float__ methods that always raise an exception.
This commit is contained in:
parent
1dbce44b91
commit
0eb2a6e974
2 changed files with 30 additions and 12 deletions
|
@ -365,10 +365,11 @@ def numops(a, b, skip=[]):
|
|||
res = eval(expr, dict)
|
||||
testbinop(a, b, res, expr, name)
|
||||
for name, expr in unops.items():
|
||||
name = "__%s__" % name
|
||||
if hasattr(a, name):
|
||||
res = eval(expr, dict)
|
||||
testunop(a, res, expr, name)
|
||||
if name not in skip:
|
||||
name = "__%s__" % name
|
||||
if hasattr(a, name):
|
||||
res = eval(expr, dict)
|
||||
testunop(a, res, expr, name)
|
||||
|
||||
def ints():
|
||||
if verbose: print "Testing int operations..."
|
||||
|
@ -384,7 +385,7 @@ def floats():
|
|||
|
||||
def complexes():
|
||||
if verbose: print "Testing complex operations..."
|
||||
numops(100.0j, 3.0j, skip=['lt', 'le', 'gt', 'ge'])
|
||||
numops(100.0j, 3.0j, skip=['lt', 'le', 'gt', 'ge', 'int', 'long', 'float'])
|
||||
class Number(complex):
|
||||
__slots__ = ['prec']
|
||||
def __new__(cls, *args, **kwds):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue