Tim Golden <m...@timgolden.me.uk> added the comment:
Problem seems to be in Modules/_multiprocessing/semaphore.c
line 549 where "__enter__" is defined as an alias for
semlock_acquire, as is "acquire" a few lines above. However,
while "acquire" specifies METH_VARARGS | METH_KEYWORDS,
"__enter__" has only METH_VARARGS.
semlock_acquire at line 60 has the signature:
SemLockObject *self, PyObject *args, PyObject *kwds
When it is called via __enter__ kwds aren't passed in
and it gets a NULL pointer.
Suggested patch attached, defining __enter__ in the same
way as acquire. Test included.
----------
keywords: +patch
Added file: http://bugs.python.org/file13090/multiprocessing.patch
_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5261>
_______________________________________
Index: Lib/test/test_multiprocessing.py
===================================================================
--- Lib/test/test_multiprocessing.py (revision 69621)
+++ Lib/test/test_multiprocessing.py (working copy)
@@ -547,6 +547,10 @@
self.assertEqual(lock.release(), None)
self.assertEqual(lock.release(), None)
self.assertRaises((AssertionError, RuntimeError), lock.release)
+
+ def test_lock_context(self):
+ with self.Lock():
+ pass
class _TestSemaphore(BaseTestCase):
Index: Modules/_multiprocessing/semaphore.c
===================================================================
--- Modules/_multiprocessing/semaphore.c (revision 69621)
+++ Modules/_multiprocessing/semaphore.c (working copy)
@@ -546,7 +546,7 @@
"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"},
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com