tw.py: get_tw_label() bugfix
This commit is contained in:
parent
9d8b90f705
commit
bc439e0b3d
4 changed files with 8 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -265,6 +265,7 @@ tests = {
|
|||
'good': (utf8_text[:48],)
|
||||
},
|
||||
'TwComment': {
|
||||
'exc_name': 'BadTwComment',
|
||||
'arg1': 's',
|
||||
'bad': ( utf8_combining[:40],
|
||||
utf8_ctrl[:40],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue