This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vajrasky
Recipients rhettinger, vajrasky
Date 2013-11-25.10:29:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1385375390.08.0.216334193444.issue19768@psf.upfronthosting.co.za>
In-reply-to
Content
>>> from collections import deque
>>> deque('abc', maxlen='a')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: an integer is required

But it's a lie. You can give None to maxlen
>>> deque('abc', maxlen=None)
deque(['a', 'b', 'c'])

maxlen with None value means unlimited.

You can give boolean value too to maxlen.

>>> deque('abc', maxlen=True)
deque(['c'], maxlen=1)

But since we use boolean and integer interchangeably in Python, so this should not matter in this case.

So, after the patch:
>>> deque('abc', maxlen='a')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: maxlen must be integer or None

Don't worry, I only overrode the TypeError one. So overflow error should be kept intact.

>>> deque('abc', maxlen=2**68)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C ssize_t

I did not override the negative integer error message, because I assume when people give negative integer, they are in the mindset of giving integer value to maxlen.

>>> deque('abc', maxlen=-3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: maxlen must be non-negative
History
Date User Action Args
2013-11-25 10:29:50vajraskysetrecipients: + vajrasky, rhettinger
2013-11-25 10:29:50vajraskysetmessageid: <1385375390.08.0.216334193444.issue19768@psf.upfronthosting.co.za>
2013-11-25 10:29:50vajraskylinkissue19768 messages
2013-11-25 10:29:49vajraskycreate