Skip to content

Commit 5c4e006

Browse files
authored
Merge pull request #365 from radix/construct-exceptions-with-saner-arguments
construct empty exceptions with no arguments, instead of () and {}
2 parents 2a3e9d1 + 8a4c199 commit 5c4e006

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

kazoo/exceptions.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ def _invalid_error_code():
5252

5353
def _zookeeper_exception(code):
5454
def decorator(klass):
55-
def create(*args, **kwargs):
56-
return klass(args, kwargs)
57-
58-
EXCEPTIONS[code] = create
55+
EXCEPTIONS[code] = klass
5956
klass.code = code
6057
return klass
6158

kazoo/tests/test_exceptions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,9 @@ def test_exceptions_code(self):
2020
def test_invalid_code(self):
2121
module = self._get()
2222
self.assertRaises(RuntimeError, module.EXCEPTIONS.__getitem__, 666)
23+
24+
def test_exceptions_construction(self):
25+
module = self._get()
26+
exc = module.EXCEPTIONS[-101]()
27+
assert type(exc) is module.NoNodeError
28+
assert exc.args == ()

0 commit comments

Comments
 (0)