New submission from sbt <[email protected]>:
The __enter__() methods of Lock, RLock, Semaphore and Condition in threading
(and multiprocessing) all return True. This seems to contradict the
documentation for the context protocol which says
contextmanager.__enter__()
Enter the runtime context and return either this object or
another object related to the runtime context. The value
returned by this method is bound to the identifier in the
as clause of with statements using this context manager.
...
I don't think True qualifies as "another object related to the runtime context".
It looks like an oversight caused by making __enter__() an alias for acquire().
Is it reasonable to change this for 3.3? I tripped over the issue when I
tried writing
with Condition() as c:
...
----------
components: Library (Lib)
messages: 154161
nosy: sbt
priority: normal
severity: normal
status: open
title: Lock.__enter__() method returns True instead of self
type: behavior
versions: Python 3.3
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue14116>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com