This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Threading Lock - Wrong Exception Name
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, docs@python, georg.brandl, mikehoy, python-dev, r.david.murray
Priority: normal Keywords: patch

Created on 2012-08-31 09:55 by mikehoy, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
15829-thread-errror3.3.diff mikehoy, 2012-08-31 12:22 review
15829-thread-errror2.7.diff mikehoy, 2012-08-31 12:23 review
Messages (12)
msg169513 - (view) Author: Mike Hoy (mikehoy) * Date: 2012-08-31 09:55
From the Docs mailing list:

>Hi

>I found a bug in python docs which can be accessed at links:
>http://docs.python.org/library/threading.html#lock-objects
>http://docs.python.org/py3k/library/threading.html#lock-objects

>Bug is in second paragraph describing threading.Lock. I found that >statement:
>"If an attempt is made to release an unlocked lock, a RuntimeError will >be raised."
>Which is not true, name of exception is wrong it should be (and it >relay is) ThreadError (from threading module)

>Could someone fix it?

>-- 
>Br,
>Slawomir Kuszczynski
msg169514 - (view) Author: Mike Hoy (mikehoy) * Date: 2012-08-31 09:56
Working on a patch now unless there are objections to the OP.
msg169516 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-08-31 10:22
The problem is: threading.Lock raises ThreadingError (which is subclass of RuntimeError for 3.3 but not for 3.2), but threading.Condition raises RuntimeError for the same reason.

RLock behavior is even worse: it raises ThreadingError if C accelerator is available in _thread and RuntimeError otherwise.

I think RuntimeError should be replaced by ThreadingError for _RLock and Condition implementations as well as docs need to be updated.

Also I think this patch should be applied to 3.4 only, it is enchacement, not bugfix.
About fixing docs for 2.7-3.3: I see nothing wrong if current inconsistency will be documented, perhaps as *warning* or *note* block.
msg169517 - (view) Author: Mike Hoy (mikehoy) * Date: 2012-08-31 10:27
>>I think RuntimeError should be replaced by ThreadingError for _RLock >>and Condition implementations as well as docs need to be updated.
>>
>>Also I think this patch should be applied to 3.4 only, it is >>enchacement, not bugfix.
>>About fixing docs for 2.7-3.3: I see nothing wrong if current >>inconsistency will be documented, perhaps as *warning* or *note* block.

I should warn that ThreadError or `ThreadError` has no link. I've tried to find a place in the docs I could link to but haven't yet. `ValueError` does have a link.
msg169519 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-08-31 10:38
ValueError can be referenced by :exc:`ValueError`.
For ThreadError you can add section for describing this exception type like:

.. exception:: ThreadError

    Raised when lock object cannot be acquired or released.
msg169524 - (view) Author: Mike Hoy (mikehoy) * Date: 2012-08-31 11:36
I discussed this in IRC and got the following information from Ezio:

< Taggnostr> the doc fix can go in 2.7/3.3, the code fix in 3.4

Plan is to put the definition for ThreadError in threading.rst for both 2.7 and 3.3
msg169525 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-08-31 11:39
Sounds good.
msg169526 - (view) Author: Mike Hoy (mikehoy) * Date: 2012-08-31 12:22
3.3 patch
msg169527 - (view) Author: Mike Hoy (mikehoy) * Date: 2012-08-31 12:23
2.7 patch.
msg169532 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-08-31 13:07
Please see Issue 14502.  The docs probably do need clarification, but it must be done carefully.
msg199670 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-13 08:23
New changeset d7e9c0a6dbcf by Georg Brandl in branch '2.7':
Closes #15829: document ThreadError and fix exception raised for releasing unlocked locks.
http://hg.python.org/cpython/rev/d7e9c0a6dbcf
msg199671 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2013-10-13 08:23
3.3 didn't need to be updated; it's RuntimeError there everywhere.
History
Date User Action Args
2022-04-11 14:57:35adminsetgithub: 60033
2013-10-13 08:23:54georg.brandlsetnosy: + georg.brandl
messages: + msg199671
2013-10-13 08:23:06python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg199670

resolution: fixed
stage: resolved
2012-08-31 13:07:09r.david.murraysetnosy: + r.david.murray
messages: + msg169532
2012-08-31 12:23:11mikehoysetfiles: + 15829-thread-errror2.7.diff

messages: + msg169527
2012-08-31 12:22:25mikehoysetfiles: + 15829-thread-errror3.3.diff
keywords: + patch
messages: + msg169526
2012-08-31 11:39:51asvetlovsetmessages: + msg169525
2012-08-31 11:36:20mikehoysetmessages: + msg169524
2012-08-31 10:38:47asvetlovsetmessages: + msg169519
2012-08-31 10:32:49asvetlovsetmessages: - msg169518
2012-08-31 10:27:21mikehoysetmessages: + msg169518
2012-08-31 10:27:19mikehoysettype: enhancement ->
messages: + msg169517
2012-08-31 10:22:40asvetlovsetnosy: + asvetlov
messages: + msg169516

components: + Library (Lib)
type: enhancement
2012-08-31 09:56:26mikehoysetnosy: + docs@python
messages: + msg169514
2012-08-31 09:55:34mikehoycreate