[issue2149] Queue.maxsize, __init__() accepts any value as maxsize

Rafael Zanella report at bugs.python.org
Thu Feb 21 00:29:28 CET 2008


Rafael Zanella added the comment:

Firts: the security type was my error.

The method wich uses the maxsize:
"""
# Check whether the queue is full
def _full(self):
  return self.maxsize > 0 and len(self.queue) == self.maxsize
"""

@rhettinger: As per the documentation, negative values result on an
infinite Queue; well that AND will never be fulfilled with a negative
value anyway;

@gutworth: What I mean is that's "awkward", if you put an string for
example, it'll be the size of the string wich will be used on the
__cmp__ and on len(), but that's not explicit, or is it?

Example:

[zan at tails ~]$ python
Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11)
[GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class C:
...   def __init__(self): pass;
...
>>> c = C()
>>> import Queue
>>> a = Queue.Queue(c)
>>> len(c)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: C instance has no attribute '__len__'
>>> a = Queue.Queue(c)
>>> a.put('q')
>>> a.get()
'q'
>>> a.put(1)
>>> a.put(2)
>>> a.put(3)
>>>

----------
type: security -> feature request

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2149>
__________________________________


More information about the Python-bugs-list mailing list