From 0967f03b40a920e6e33453c04c4c0ea583131cb3 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Sun, 3 Nov 2019 14:10:21 +0200 Subject: [PATCH] addresses: raise varintEncodeError in encodeVarint() instead of SystemExit (looks like a bug) --- src/addresses.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/addresses.py b/src/addresses.py index 533ec169..b83f3f6e 100644 --- a/src/addresses.py +++ b/src/addresses.py @@ -54,11 +54,20 @@ def decodeBase58(string, alphabet=ALPHABET): return num +class varintEncodeError(Exception): + """Exception class for encoding varint""" + pass + + +class varintDecodeError(Exception): + """Exception class for decoding varint data""" + pass + + def encodeVarint(integer): """Convert integer into varint bytes""" if integer < 0: - logger.error('varint cannot be < 0') - raise SystemExit + raise varintEncodeError('varint cannot be < 0') if integer < 253: return pack('>B', integer) if integer >= 253 and integer < 65536: @@ -68,13 +77,7 @@ def encodeVarint(integer): if integer >= 4294967296 and integer < 18446744073709551616: return pack('>B', 255) + pack('>Q', integer) if integer >= 18446744073709551616: - logger.error('varint cannot be >= 18446744073709551616') - raise SystemExit - - -class varintDecodeError(Exception): - """Exception class for decoding varint data""" - pass + raise varintEncodeError('varint cannot be >= 18446744073709551616') def decodeVarint(data):