(cls, other)
| 662 | """ |
| 663 | @classmethod |
| 664 | def __coerce_instance(cls, other): |
| 665 | # Coerce other into bytes |
| 666 | if isinstance(other, CScriptOp): |
| 667 | other = bchr(other) |
| 668 | elif isinstance(other, CScriptNum): |
| 669 | if (other.value == 0): |
| 670 | other = bchr(CScriptOp(OP_0)) |
| 671 | else: |
| 672 | other = CScriptNum.encode(other) |
| 673 | elif isinstance(other, int): |
| 674 | if 0 <= other <= 16: |
| 675 | other = bytes(bchr(CScriptOp.encode_op_n(other))) |
| 676 | elif other == -1: |
| 677 | other = bytes(bchr(OP_1NEGATE)) |
| 678 | else: |
| 679 | other = CScriptOp.encode_op_pushdata(bn2vch(other)) |
| 680 | elif isinstance(other, (bytes, bytearray)): |
| 681 | other = CScriptOp.encode_op_pushdata(other) |
| 682 | return other |
| 683 | |
| 684 | def __add__(self, other): |
| 685 | # Do the coercion outside of the try block so that errors in it are |
no test coverage detected