diff --git a/NEWS.rst b/NEWS.rst index f25f0a6..fd3cde5 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -5,6 +5,8 @@ Release History 0.3 (2012-01-XX) ~~~~~~~~~~~~~~~~ +* Issue #5: ContextStack.register no longer pointlessly returns the wrapped + function * Issue #2: Add examples and recipes section to docs * Issue #3: ContextStack.register_exit() now accepts objects with __exit__ attributes in addition to accepting exit callbacks directly diff --git a/contextlib2.py b/contextlib2.py index 2b95040..a9c24a3 100644 --- a/contextlib2.py +++ b/contextlib2.py @@ -187,7 +187,7 @@ class ContextStack(object): @wraps(callback) def _wrapper(exc_type, exc, tb): callback(*args, **kwds) - return self.register_exit(_wrapper) + self.register_exit(_wrapper) def enter_context(self, cm): """Enters the supplied context manager diff --git a/test_contextlib2.py b/test_contextlib2.py index 31b95b0..8ee7bdb 100755 --- a/test_contextlib2.py +++ b/test_contextlib2.py @@ -322,13 +322,13 @@ class TestContextStack(unittest.TestCase): with ContextStack() as stack: for args, kwds in reversed(expected): if args and kwds: - stack.register(_exit, *args, **kwds) + self.assertIsNone(stack.register(_exit, *args, **kwds)) elif args: - stack.register(_exit, *args) + self.assertIsNone(stack.register(_exit, *args)) elif kwds: - stack.register(_exit, **kwds) + self.assertIsNone(stack.register(_exit, **kwds)) else: - stack.register(_exit) + self.assertIsNone(stack.register(_exit)) for wrapper in stack._callbacks: self.assertEqual(wrapper.__name__, _exit.__name__) self.assertEqual(wrapper.__doc__, _exit.__doc__)