(cls, other)
| 650 | """ |
| 651 | @classmethod |
| 652 | def __coerce_instance(cls, other): |
| 653 | # Coerce other into bytes |
| 654 | if isinstance(other, CScriptOp): |
| 655 | other = bchr(other) |
| 656 | elif isinstance(other, CScriptNum): |
| 657 | if (other.value == 0): |
| 658 | other = bchr(CScriptOp(OP_0)) |
| 659 | else: |
| 660 | other = CScriptNum.encode(other) |
| 661 | elif isinstance(other, (int, long)): |
| 662 | if 0 <= other <= 16: |
| 663 | other = bytes(bchr(CScriptOp.encode_op_n(other))) |
| 664 | elif other == -1: |
| 665 | other = bytes(bchr(OP_1NEGATE)) |
| 666 | else: |
| 667 | other = CScriptOp.encode_op_pushdata(bn2vch(other)) |
| 668 | elif isinstance(other, (bytes, bytearray)): |
| 669 | other = CScriptOp.encode_op_pushdata(other) |
| 670 | return other |
| 671 | |
| 672 | def __add__(self, other): |
| 673 | # Do the coercion outside of the try block so that errors in it are |
no test coverage detected