mirror of
https://github.com/python/cpython.git
synced 2025-09-19 15:10:58 +00:00
Issue #11140: Lock.release() now raises a RuntimeError when attempting
to release an unacquired lock, as claimed in the threading documentation. The _thread.error exception is now an alias of RuntimeError.
This commit is contained in:
parent
cfbcec3823
commit
fcf81fd031
4 changed files with 14 additions and 1 deletions
|
@ -35,6 +35,9 @@ It defines the following constants and functions:
|
||||||
|
|
||||||
Raised on thread-specific errors.
|
Raised on thread-specific errors.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.3
|
||||||
|
This is now a synonym of the built-in :exc:`RuntimeError`.
|
||||||
|
|
||||||
|
|
||||||
.. data:: LockType
|
.. data:: LockType
|
||||||
|
|
||||||
|
|
|
@ -685,6 +685,10 @@ class ThreadingExceptionTests(BaseTestCase):
|
||||||
thread.start()
|
thread.start()
|
||||||
self.assertRaises(RuntimeError, setattr, thread, "daemon", True)
|
self.assertRaises(RuntimeError, setattr, thread, "daemon", True)
|
||||||
|
|
||||||
|
def test_releasing_unacquired_lock(self):
|
||||||
|
lock = threading.Lock()
|
||||||
|
self.assertRaises(RuntimeError, lock.release)
|
||||||
|
|
||||||
|
|
||||||
class LockTests(lock_tests.LockTests):
|
class LockTests(lock_tests.LockTests):
|
||||||
locktype = staticmethod(threading.Lock)
|
locktype = staticmethod(threading.Lock)
|
||||||
|
|
|
@ -35,6 +35,10 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #11140: Lock.release() now raises a RuntimeError when attempting
|
||||||
|
to release an unacquired lock, as claimed in the threading documentation.
|
||||||
|
The _thread.error exception is now an alias of RuntimeError.
|
||||||
|
|
||||||
- Issue 8594: ftplib now provides a source_address parameter to specify which
|
- Issue 8594: ftplib now provides a source_address parameter to specify which
|
||||||
(address, port) to bind to before connecting.
|
(address, port) to bind to before connecting.
|
||||||
|
|
||||||
|
|
|
@ -1308,7 +1308,9 @@ PyInit__thread(void)
|
||||||
|
|
||||||
/* Add a symbolic constant */
|
/* Add a symbolic constant */
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
ThreadError = PyErr_NewException("_thread.error", NULL, NULL);
|
ThreadError = PyExc_RuntimeError;
|
||||||
|
Py_INCREF(ThreadError);
|
||||||
|
|
||||||
PyDict_SetItemString(d, "error", ThreadError);
|
PyDict_SetItemString(d, "error", ThreadError);
|
||||||
Locktype.tp_doc = lock_doc;
|
Locktype.tp_doc = lock_doc;
|
||||||
Py_INCREF(&Locktype);
|
Py_INCREF(&Locktype);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue