aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHartmut Goebel <h.goebel@crazy-compilers.com>2019-01-19 19:53:29 +0100
committerHartmut Goebel <h.goebel@crazy-compilers.com>2019-01-19 19:53:29 +0100
commit602cde1ebff40544c66ae769426825b5fc400167 (patch)
tree6fc2f3ce18b68a457f9889a5645c41b58df8b1fb
parent41724f12889455473a83fba459a709791005d5c2 (diff)
downloadgnunet-python-602cde1ebff40544c66ae769426825b5fc400167.tar.gz
gnunet-python-602cde1ebff40544c66ae769426825b5fc400167.zip
Avoid "During handling of the above exception" when re-raising.
-rw-r--r--gnunet/__init__.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/gnunet/__init__.py b/gnunet/__init__.py
index c4c5648..5bae6f0 100644
--- a/gnunet/__init__.py
+++ b/gnunet/__init__.py
@@ -14,10 +14,12 @@ class _Key:
14 else: 14 else:
15 try: 15 try:
16 self._data = bytearray(arg) 16 self._data = bytearray(arg)
17 except: 17 except TypeError as e:
18 raise TypeError("'arg' must be a %s, a string or an array " 18 # HACK: replace the exception message
19 "of bytes. Not a '%s'." % 19 e.args = ("'arg' must be a %s, a string or an array "
20 (type(self).__name__, type(arg).__name__),) 20 "of bytes. Not a '%s'." %
21 (type(self).__name__, type(arg).__name__),)
22 raise
21 23
22 if len(self._data) * 8 != self.__bits__: 24 if len(self._data) * 8 != self.__bits__:
23 raise ValueError("'arg' must be a %s bit hash. Got %s bits." 25 raise ValueError("'arg' must be a %s bit hash. Got %s bits."