From bc439e0b3d651fe9b417f457c3ce348e623305b6 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 1 Jun 2020 21:34:11 +0000 Subject: [PATCH] tw.py: get_tw_label() bugfix --- mmgen/exception.py | 1 + mmgen/obj.py | 1 + mmgen/tw.py | 6 +++++- test/objtest_py_d/ot_btc_mainnet.py | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mmgen/exception.py b/mmgen/exception.py index 2dee1fa0..83e8a2bf 100755 --- a/mmgen/exception.py +++ b/mmgen/exception.py @@ -40,6 +40,7 @@ class InvalidTokenAddress(Exception): mmcode = 2 class UnrecognizedTokenSymbol(Exception): mmcode = 2 class TokenNotInBlockchain(Exception): mmcode = 2 class TokenNotInWallet(Exception): mmcode = 2 +class BadTwComment(Exception): mmcode = 2 class BadTwLabel(Exception): mmcode = 2 class BaseConversionError(Exception): mmcode = 2 class BaseConversionPadError(Exception): mmcode = 2 diff --git a/mmgen/obj.py b/mmgen/obj.py index a2e7624a..ef4a388e 100755 --- a/mmgen/obj.py +++ b/mmgen/obj.py @@ -876,6 +876,7 @@ class MMGenWalletLabel(MMGenLabel): class TwComment(MMGenLabel): max_screen_width = 80 desc = 'tracking wallet comment' + exc = BadTwComment class MMGenTxLabel(MMGenLabel): max_len = 72 diff --git a/mmgen/tw.py b/mmgen/tw.py index e839da6c..ca4bb825 100755 --- a/mmgen/tw.py +++ b/mmgen/tw.py @@ -32,9 +32,13 @@ CUR_HOME,ERASE_ALL = '\033[H','\033[0J' def CUR_RIGHT(n): return '\033[{}C'.format(n) def get_tw_label(proto,s): + """ + We must fail only on malformed comment, not on empty label. + Otherwise, listaddresses showempty=1 will fail. + """ try: return TwLabel(proto,s) - except BadTwLabel: + except BadTwComment: raise except: return None diff --git a/test/objtest_py_d/ot_btc_mainnet.py b/test/objtest_py_d/ot_btc_mainnet.py index ee2a15a4..2ecf97ec 100755 --- a/test/objtest_py_d/ot_btc_mainnet.py +++ b/test/objtest_py_d/ot_btc_mainnet.py @@ -265,6 +265,7 @@ tests = { 'good': (utf8_text[:48],) }, 'TwComment': { + 'exc_name': 'BadTwComment', 'arg1': 's', 'bad': ( utf8_combining[:40], utf8_ctrl[:40],