t is the testset. At this stage the testset contains operand lists t.cop and t.pop for the C and Python versions of decimal. For Decimal methods, the first operands are of type C.Decimal and P.Decimal respectively. The remaining operands can have various types. For C
(t)
| 756 | return 1 |
| 757 | |
| 758 | def callfuncs(t): |
| 759 | """ t is the testset. At this stage the testset contains operand lists |
| 760 | t.cop and t.pop for the C and Python versions of decimal. |
| 761 | For Decimal methods, the first operands are of type C.Decimal and |
| 762 | P.Decimal respectively. The remaining operands can have various types. |
| 763 | For Context methods, all operands can have any type. |
| 764 | |
| 765 | t.rc and t.rp are the results of the operation. |
| 766 | """ |
| 767 | context.clear_status() |
| 768 | t.maxcontext.clear_flags() |
| 769 | |
| 770 | try: |
| 771 | if t.contextfunc: |
| 772 | cargs = t.cop |
| 773 | t.rc = getattr(context.c, t.funcname)(*cargs) |
| 774 | else: |
| 775 | cself = t.cop[0] |
| 776 | cargs = t.cop[1:] |
| 777 | t.rc = getattr(cself, t.funcname)(*cargs) |
| 778 | t.cex.append(None) |
| 779 | except (TypeError, ValueError, OverflowError, MemoryError) as e: |
| 780 | t.rc = None |
| 781 | t.cex.append(e.__class__) |
| 782 | |
| 783 | try: |
| 784 | if t.contextfunc: |
| 785 | pargs = t.pop |
| 786 | t.rp = getattr(context.p, t.funcname)(*pargs) |
| 787 | else: |
| 788 | pself = t.pop[0] |
| 789 | pargs = t.pop[1:] |
| 790 | t.rp = getattr(pself, t.funcname)(*pargs) |
| 791 | t.pex.append(None) |
| 792 | except (TypeError, ValueError, OverflowError, MemoryError) as e: |
| 793 | t.rp = None |
| 794 | t.pex.append(e.__class__) |
| 795 | |
| 796 | # If the above results are exact, unrounded, normal etc., repeat the |
| 797 | # operation with a maxcontext to ensure that huge intermediate values |
| 798 | # do not cause a MemoryError. |
| 799 | if (t.funcname not in MaxContextSkip and |
| 800 | not context.c.flags[C.InvalidOperation] and |
| 801 | not context.c.flags[C.Inexact] and |
| 802 | not context.c.flags[C.Rounded] and |
| 803 | not context.c.flags[C.Subnormal] and |
| 804 | not context.c.flags[C.Clamped] and |
| 805 | not context.clamp and # results are padded to context.prec if context.clamp==1. |
| 806 | not any(isinstance(v, C.Context) for v in t.cop)): # another context is used. |
| 807 | t.with_maxcontext = True |
| 808 | try: |
| 809 | if t.contextfunc: |
| 810 | maxargs = t.maxop |
| 811 | t.rmax = getattr(t.maxcontext, t.funcname)(*maxargs) |
| 812 | else: |
| 813 | maxself = t.maxop[0] |
| 814 | maxargs = t.maxop[1:] |
| 815 | try: |
searching dependent graphs…