(cls, other)
| 439 | |
| 440 | @classmethod |
| 441 | def __coerce_instance(cls, other): |
| 442 | # Coerce other into bytes |
| 443 | if isinstance(other, CScriptOp): |
| 444 | other = bytes([other]) |
| 445 | elif isinstance(other, CScriptNum): |
| 446 | if (other.value == 0): |
| 447 | other = bytes([CScriptOp(OP_0)]) |
| 448 | else: |
| 449 | other = CScriptNum.encode(other) |
| 450 | elif isinstance(other, int): |
| 451 | if 0 <= other <= 16: |
| 452 | other = bytes([CScriptOp.encode_op_n(other)]) |
| 453 | elif other == -1: |
| 454 | other = bytes([OP_1NEGATE]) |
| 455 | else: |
| 456 | other = CScriptOp.encode_op_pushdata(bn2vch(other)) |
| 457 | elif isinstance(other, (bytes, bytearray)): |
| 458 | other = CScriptOp.encode_op_pushdata(other) |
| 459 | return other |
| 460 | |
| 461 | def __add__(self, other): |
| 462 | # add makes no sense for a CScript() |
no test coverage detected