tlnonion: get_failure_msg_from_onion_error might raise in python 3.7 - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 2a604b1676680859d5ddb84f132ec39a6c1b5c80 DIR parent c37d08cec9c5c9fbc473151b2b77343cefeae7c9 HTML Author: SomberNight <somber.night@protonmail.com> Date: Sat, 12 Oct 2019 00:05:38 +0200 lnonion: get_failure_msg_from_onion_error might raise in python 3.7 tthis used to work in py3.6 but raises in py3.7 :( (see https://bugs.python.org/issue34536) Diffstat: M electrum/lnonion.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) --- DIR diff --git a/electrum/lnonion.py b/electrum/lnonion.py t@@ -348,7 +348,10 @@ def get_failure_msg_from_onion_error(decrypted_error_packet: bytes) -> OnionRout failure_msg = decrypted_error_packet[34:34+failure_len] # create failure message object failure_code = int.from_bytes(failure_msg[:2], byteorder='big') - failure_code = OnionFailureCode(failure_code) + try: + failure_code = OnionFailureCode(failure_code) + except ValueError: + pass # uknown failure code failure_data = failure_msg[2:] return OnionRoutingFailureMessage(failure_code, failure_data) t@@ -387,12 +390,6 @@ class OnionFailureCode(IntEnum): CHANNEL_DISABLED = UPDATE | 20 EXPIRY_TOO_FAR = 21 - @classmethod - def _missing_(cls, value: int) -> int: - # note that for unknown error codes, we return an int, - # not an instance of cls - return value - # don't use these elsewhere, the names are ambiguous without context del BADONION; del PERM; del NODE; del UPDATE