classification
Title: Thread.LockType is misnamed
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: cindykrafft, josh.r
Priority: normal Keywords:

Created on 2015-01-28 06:02 by cindykrafft, last changed 2015-02-03 03:16 by josh.r.

Messages (2)
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.
History
Date User Action Args
2015-02-03 03:16:31josh.rsetnosy: + josh.r
messages: + msg235313
2015-01-28 06:02:27cindykrafftcreate