Updated code quality replaced unicode by decode function in api.py

This commit is contained in:
kuldeep.k@cisinlabs.com 2021-08-27 21:47:24 +05:30
parent 3450066ea2
commit 7702b33ac2
No known key found for this signature in database
GPG Key ID: AF4FB299BF7C7C2A

View File

@ -642,7 +642,7 @@ class BMRPCDispatcher(object):
% type(eighteenByteRipe)) % type(eighteenByteRipe))
label = self._decode(label, "base64") label = self._decode(label, "base64")
try: try:
unicode(label, 'utf-8') label.decode('utf-8')
except UnicodeDecodeError: except UnicodeDecodeError:
raise APIError(17, 'Label is not valid UTF-8 data.') raise APIError(17, 'Label is not valid UTF-8 data.')
queues.apiAddressGeneratorReturnQueue.queue.clear() queues.apiAddressGeneratorReturnQueue.queue.clear()
@ -773,7 +773,7 @@ class BMRPCDispatcher(object):
# It would be nice to make the label the passphrase but it is # It would be nice to make the label the passphrase but it is
# possible that the passphrase contains non-utf-8 characters. # possible that the passphrase contains non-utf-8 characters.
try: try:
unicode(passphrase, 'utf-8') passphrase.decode('utf-8')
label = str_chan + ' ' + passphrase label = str_chan + ' ' + passphrase
except UnicodeDecodeError: except UnicodeDecodeError:
label = str_chan + ' ' + repr(passphrase) label = str_chan + ' ' + repr(passphrase)
@ -805,7 +805,7 @@ class BMRPCDispatcher(object):
# It would be nice to make the label the passphrase but it is # It would be nice to make the label the passphrase but it is
# possible that the passphrase contains non-utf-8 characters. # possible that the passphrase contains non-utf-8 characters.
try: try:
unicode(passphrase, 'utf-8') passphrase.decode('utf-8')
label = str_chan + ' ' + passphrase label = str_chan + ' ' + passphrase
except UnicodeDecodeError: except UnicodeDecodeError:
label = str_chan + ' ' + repr(passphrase) label = str_chan + ' ' + repr(passphrase)
@ -1192,7 +1192,7 @@ class BMRPCDispatcher(object):
if label: if label:
label = self._decode(label, "base64") label = self._decode(label, "base64")
try: try:
unicode(label, 'utf-8') label.decode('utf-8')
except UnicodeDecodeError: except UnicodeDecodeError:
raise APIError(17, 'Label is not valid UTF-8 data.') raise APIError(17, 'Label is not valid UTF-8 data.')
self._verifyAddress(address) self._verifyAddress(address)