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: Thread.LockType is misnamed
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: cindykrafft, iritkatriel, josh.r
Priority: normal Keywords:

Created on 2015-01-28 06:02 by cindykrafft, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg234873 - (view) Author: (cindykrafft) Date: 2015-01-28 06:02
The tp_name field in thread.LockType is set as "thread.lock". This is incorrect and conflicts with the value set in dummy_thread.

Python 2.7.6 (default, Sep  9 2014, 15:04:36) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import thread
>>> import dummy_thread
>>> thread.LockType.__name__
'lock'
>>> dummy_thread.LockType.__name__
'LockType'

Code which depends on the ability to look up a class based on module and name (see the following code taken from pickle.py) breaks due to this behavior, so my preferred fix would be to change tp_name to a value consistent with dummy_thread.

try:
    __import__(module)
    mod = sys.modules[module]
    klass = getattr(mod, name)
except (ImportError, KeyError, AttributeError):
    raise PicklingError(
        "Can't pickle %r: it's not found as %s.%s" %
         (obj, module, name))

Happy to submit a patch if someone could confirm.
msg235313 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2015-02-03 03:16
The thread and dummy_thread modules have a leading underscore in Py3.4, but the same naming issue is present there as well.
msg391944 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-04-26 15:41
_dummy_thread and dummy_threading modules have been removed in V3.9.
History
Date User Action Args
2022-04-11 14:58:12adminsetgithub: 67525
2021-04-26 15:41:12iritkatrielsetstatus: open -> closed

nosy: + iritkatriel
messages: + msg391944

resolution: out of date
stage: resolved
2015-02-03 03:16:31josh.rsetnosy: + josh.r
messages: + msg235313
2015-01-28 06:02:27cindykrafftcreate