Message204321
>>> 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 |
|
Date |
User |
Action |
Args |
2013-11-25 10:29:50 | vajrasky | set | recipients:
+ vajrasky, rhettinger |
2013-11-25 10:29:50 | vajrasky | set | messageid: <1385375390.08.0.216334193444.issue19768@psf.upfronthosting.co.za> |
2013-11-25 10:29:50 | vajrasky | link | issue19768 messages |
2013-11-25 10:29:49 | vajrasky | create | |
|