[New-bugs-announce] [issue23336] Thread.LockType is misnamed

cindykrafft report at bugs.python.org
Wed Jan 28 07:02:27 CET 2015


New submission from cindykrafft:

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.

----------
components: Library (Lib)
messages: 234873
nosy: cindykrafft
priority: normal
severity: normal
status: open
title: Thread.LockType is misnamed
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23336>
_______________________________________


More information about the New-bugs-announce mailing list