[issue34180] bool(Q) always return True for a priority queue Q

2018-07-22 Thread Tim Peters
Tim Peters added the comment: I'm sure Guido designed the API to discourage subtly bug-ridden code relying on the mistaken belief that it _can_ know the queue's current size. In the general multi-threaded context Queue is intended to be used, the only thing `.qsize()`'s caller can know is

[issue34180] bool(Q) always return True for a priority queue Q

2018-07-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: The class is not documented to support __len__() or __bool__(), so this is not a bug. There is an empty() method provided for the purposes of testing whether a queue is empty or not. Likewise, there is a qsize() method for determining the current size.

[issue34180] bool(Q) always return True for a priority queue Q

2018-07-21 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Relevant SO answer : https://stackoverflow.com/a/41861322/2610955 Ref : https://docs.python.org/3/reference/datamodel.html#object.__bool__ > If a class defines neither __len__() nor __bool__(), all its instances are > considered true. I don't know

[issue34180] bool(Q) always return True for a priority queue Q

2018-07-21 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- assignee: -> rhettinger nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue34180] bool(Q) always return True for a priority queue Q

2018-07-21 Thread Victor Porton
New submission from Victor Porton : It seems that bool(Q) always return True for a priority queue Q. It should behave the same way as for bool(L) where L is a list, that is return False on an empty queue. Please check also other objects in https://docs.python.org/3/library/queue.html After