t is the testset. At this stage the testset contains a tuple of operands t.op of various types. For decimal methods the first operand (self) is always converted to Decimal. If 'convstr' is true, string operands are converted as well. Context operands are of type dec
(t, convstr=True)
| 673 | return False |
| 674 | |
| 675 | def convert(t, convstr=True): |
| 676 | """ t is the testset. At this stage the testset contains a tuple of |
| 677 | operands t.op of various types. For decimal methods the first |
| 678 | operand (self) is always converted to Decimal. If 'convstr' is |
| 679 | true, string operands are converted as well. |
| 680 | |
| 681 | Context operands are of type deccheck.Context, rounding mode |
| 682 | operands are given as a tuple (C.rounding, P.rounding). |
| 683 | |
| 684 | Other types (float, int, etc.) are left unchanged. |
| 685 | """ |
| 686 | for i, op in enumerate(t.op): |
| 687 | |
| 688 | context.clear_status() |
| 689 | t.maxcontext.clear_flags() |
| 690 | |
| 691 | if op in RoundModes: |
| 692 | t.cop.append(op) |
| 693 | t.pop.append(op) |
| 694 | t.maxop.append(op) |
| 695 | |
| 696 | elif not t.contextfunc and i == 0 or \ |
| 697 | convstr and isinstance(op, str): |
| 698 | try: |
| 699 | c = C.Decimal(op) |
| 700 | cex = None |
| 701 | except (TypeError, ValueError, OverflowError) as e: |
| 702 | c = None |
| 703 | cex = e.__class__ |
| 704 | |
| 705 | try: |
| 706 | p = RestrictedDecimal(op) |
| 707 | pex = None |
| 708 | except (TypeError, ValueError, OverflowError) as e: |
| 709 | p = None |
| 710 | pex = e.__class__ |
| 711 | |
| 712 | try: |
| 713 | C.setcontext(t.maxcontext) |
| 714 | maxop = C.Decimal(op) |
| 715 | maxex = None |
| 716 | except (TypeError, ValueError, OverflowError) as e: |
| 717 | maxop = None |
| 718 | maxex = e.__class__ |
| 719 | finally: |
| 720 | C.setcontext(context.c) |
| 721 | |
| 722 | t.cop.append(c) |
| 723 | t.cex.append(cex) |
| 724 | |
| 725 | t.pop.append(p) |
| 726 | t.pex.append(pex) |
| 727 | |
| 728 | t.maxop.append(maxop) |
| 729 | t.maxex.append(maxex) |
| 730 | |
| 731 | if cex is pex: |
| 732 | if str(c) != str(p) or not context.assert_eq_status(): |
searching dependent graphs…