[RFC/MERGE][#243391] _run_and_cleanup helper (alternative to try/finally)
John Arbash Meinel
john at arbash-meinel.com
Wed Oct 8 20:49:32 BST 2008
-----BEGIN PGP SIGNED MESSAGE-----
Andrew Bennetts wrote:
> Andrew Bennetts wrote:
>> Hi all,
>> This patch is an extension of my fix for bug 230902 at
> Ahem. Attached this time.
+def _run_and_cleanup(cleanup, callable, *args, **kwargs):
+ """Like ``callable(*args, **kwargs); cleanup()``, but errors from
^- I think the docstring is a bit confusing. The first three times I
read it, I thought it was wrong, though I now understand it. I don't
have much better to say, though perhaps split the "but errors from" out
into another sentence, where you have room to really describe it.
Also, 'callable' is a builtin, so it is nice to not use it for variable
=== modified file 'bzrlib/tests/test_branch.py'
- --- bzrlib/tests/test_branch.py 2008-07-22 19:48:40 +0000
+++ bzrlib/tests/test_branch.py 2008-10-07 11:54:11 +0000
@@ -41,6 +41,7 @@
from bzrlib.bzrdir import (BzrDirMetaFormat1, BzrDirMeta1,
@@ -438,3 +439,70 @@
# it's still supported
a = "%d revisions pulled" % r
self.assertEqual(a, "10 revisions pulled")
+ """Helper for TestRunWithWriteLockedTarget."""
^- too many spaces here
Otherwise I think I like it. Though you should consider Aaron's
suggestion about using a class rather than a simple function.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the bazaar