summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2018-08-05 10:24:50 +0200
committerIlya Etingof <etingof@gmail.com>2018-08-05 10:24:50 +0200
commitd72ad91b3a356e09479ca1b30b36e323ea0bdb8f (patch)
tree4ce9a2d37fc26e7b5fae260d16c1c42d2d794921
parent36f7584402aa8f1c3da538f2f331e980344c719a (diff)
downloadpysnmp-git-d72ad91b3a356e09479ca1b30b36e323ea0bdb8f.tar.gz
Fix PySnmpError implementation
This is a follow up fix to make PySnmpError properly overriding base Exception call signature
-rw-r--r--pysnmp/error.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/pysnmp/error.py b/pysnmp/error.py
index b5bb35b5..e47f4bcb 100644
--- a/pysnmp/error.py
+++ b/pysnmp/error.py
@@ -9,6 +9,15 @@ import sys
class PySnmpError(Exception):
- def __init__(self, message):
+ def __init__(self, *args):
+ msg = args and str(args[0]) or ''
+
self.cause = sys.exc_info()
- Exception.__init__(self, '%s, caused by %s: %s' % (message, self.cause[0], self.cause[1]))
+
+ if self.cause[0]:
+ msg += 'caused by %s: %s' % (self.cause[0], self.cause[1])
+
+ if msg:
+ args = (msg,) + args[1:]
+
+ Exception.__init__(self, *args)