]> granicus.if.org Git - python/commitdiff
merge 70783 to py3k
authorJesse Noller <jnoller@gmail.com>
Tue, 31 Mar 2009 03:25:07 +0000 (03:25 +0000)
committerJesse Noller <jnoller@gmail.com>
Tue, 31 Mar 2009 03:25:07 +0000 (03:25 +0000)
Lib/test/test_multiprocessing.py
Misc/ACKS
Misc/NEWS
Modules/_multiprocessing/semaphore.c

index ed8c62630b289f222a2f470a4fb86446ca7e51e6..29f823de08037fb69f11568edc852134a0fbdb37 100644 (file)
@@ -548,6 +548,10 @@ class _TestLock(BaseTestCase):
         self.assertEqual(lock.release(), None)
         self.assertRaises((AssertionError, RuntimeError), lock.release)
 
+    def test_lock_context(self):
+        with self.Lock():
+            pass
+
 
 class _TestSemaphore(BaseTestCase):
 
index 03ed92de10f6c8cbbb042b0b174b2db3a1f391b4..bd300de67e39fbbe6c522527623297ec3df84ac7 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -257,6 +257,7 @@ Dinu Gherman
 Jonathan Giddy
 Johannes Gijsbers
 Michael Gilfix
+Tim Golden
 Chris Gonnerman
 David Goodger
 Hans de Graaff
@@ -794,4 +795,3 @@ Siebren van der Zee
 Uwe Zessin
 Tarek Ziad\8e
 Peter Åstrand
-Jesse Noller
index de4245a9c66657e922ccead720e8632d23e601bd..894aa71888136492d2eff941cb416d36d3dfc085 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -49,6 +49,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #5261: Patch multiprocessing's semaphore.c to support context
+  manager use: "with multiprocessing.Lock()" works now.
+
 - Issue #5236: Change time.strptime() to only take strings. Didn't work with
   bytes already but the failure was non-obvious.
 
index 9c8c445eb6f46536f8ee199aae397666b126c7a0..40bd7c3c88c3fd2c1479c01789f3f6e207194c77 100644 (file)
@@ -546,7 +546,7 @@ static PyMethodDef semlock_methods[] = {
         "acquire the semaphore/lock"},
        {"release", (PyCFunction)semlock_release, METH_NOARGS, 
         "release the semaphore/lock"},
-       {"__enter__", (PyCFunction)semlock_acquire, METH_VARARGS,
+    {"__enter__", (PyCFunction)semlock_acquire, METH_VARARGS | METH_KEYWORDS,
         "enter the semaphore/lock"},
        {"__exit__", (PyCFunction)semlock_release, METH_VARARGS, 
         "exit the semaphore/lock"},