(cls, other)
| 395 | """ |
| 396 | @classmethod |
| 397 | def __coerce_instance(cls, other): |
| 398 | # Coerce other into bytes |
| 399 | if isinstance(other, CScriptOp): |
| 400 | other = bytes([other]) |
| 401 | elif isinstance(other, CScriptNum): |
| 402 | if (other.value == 0): |
| 403 | other = bytes([CScriptOp(OP_0)]) |
| 404 | else: |
| 405 | other = CScriptNum.encode(other) |
| 406 | elif isinstance(other, int): |
| 407 | if 0 <= other <= 16: |
| 408 | other = bytes([CScriptOp.encode_op_n(other)]) |
| 409 | elif other == -1: |
| 410 | other = bytes([OP_1NEGATE]) |
| 411 | else: |
| 412 | other = CScriptOp.encode_op_pushdata(bn2vch(other)) |
| 413 | elif isinstance(other, (bytes, bytearray)): |
| 414 | other = CScriptOp.encode_op_pushdata(other) |
| 415 | return other |
| 416 | |
| 417 | def __add__(self, other): |
| 418 | # Do the coercion outside of the try block so that errors in it are |
no test coverage detected