URI: 
       tlnbase: do not catch all exceptions, tolerate calculations with variables from kwargs - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 94b87ac7d1a61648275260f7fd2aa440ac880e8e
   DIR parent 3795770b37fb3df3e6204b09e56d0a2c3c31facd
  HTML Author: Janus <ysangkok@gmail.com>
       Date:   Wed, 11 Apr 2018 11:07:30 +0200
       
       lnbase: do not catch all exceptions, tolerate calculations with variables from kwargs
       
       Diffstat:
         M lib/lnbase.py                       |       8 +++++---
       
       1 file changed, 5 insertions(+), 3 deletions(-)
       ---
   DIR diff --git a/lib/lnbase.py b/lib/lnbase.py
       t@@ -97,8 +97,10 @@ def gen_msg(msg_type, **kwargs):
                poslenMap = typ["payload"][k]
                leng = calcexp(poslenMap["length"], lengths)
                try:
       -            leng = kwargs[poslenMap["length"]]
       -        except:
       +            clone = dict(lengths)
       +            clone.update(kwargs)
       +            leng = calcexp(poslenMap["length"], clone)
       +        except KeyError:
                    pass
                try:
                    param = kwargs[k]
       t@@ -106,7 +108,7 @@ def gen_msg(msg_type, **kwargs):
                    param = 0
                try:
                    param = param.to_bytes(length=leng, byteorder="big")
       -        except:
       +        except ValueError:
                    raise Exception("{} does not fit in {} bytes".format(k, leng))
                lengths[k] = len(param)
                data += param