diff options
author | Hartmut Goebel <h.goebel@crazy-compilers.com> | 2019-01-19 19:53:29 +0100 |
---|---|---|
committer | Hartmut Goebel <h.goebel@crazy-compilers.com> | 2019-01-19 19:53:29 +0100 |
commit | 602cde1ebff40544c66ae769426825b5fc400167 (patch) | |
tree | 6fc2f3ce18b68a457f9889a5645c41b58df8b1fb | |
parent | 41724f12889455473a83fba459a709791005d5c2 (diff) |
Avoid "During handling of the above exception" when re-raising.
-rw-r--r-- | gnunet/__init__.py | 10 |
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: else: try: self._data = bytearray(arg) - except: - raise TypeError("'arg' must be a %s, a string or an array " - "of bytes. Not a '%s'." % - (type(self).__name__, type(arg).__name__),) + except TypeError as e: + # HACK: replace the exception message + e.args = ("'arg' must be a %s, a string or an array " + "of bytes. Not a '%s'." % + (type(self).__name__, type(arg).__name__),) + raise if len(self._data) * 8 != self.__bits__: raise ValueError("'arg' must be a %s bit hash. Got %s bits." |