mirror of https://github.com/python/cpython
Fix bug 1604. deque.__init__() did not clear existing contents like list.__init__. Not a backport candidate.
This commit is contained in:
parent
842c178442
commit
adf9ffdfbe
|
@ -29,8 +29,8 @@ class MutateCmp:
|
|||
class TestBasic(unittest.TestCase):
|
||||
|
||||
def test_basics(self):
|
||||
d = deque(xrange(100))
|
||||
d.__init__(xrange(100, 200))
|
||||
d = deque(xrange(-5125, -5000))
|
||||
d.__init__(xrange(200))
|
||||
for i in xrange(200, 400):
|
||||
d.append(i)
|
||||
for i in reversed(xrange(-200, 0)):
|
||||
|
@ -451,8 +451,8 @@ class DequeWithBadIter(deque):
|
|||
class TestSubclass(unittest.TestCase):
|
||||
|
||||
def test_basics(self):
|
||||
d = Deque(xrange(100))
|
||||
d.__init__(xrange(100, 200))
|
||||
d = Deque(xrange(25))
|
||||
d.__init__(xrange(200))
|
||||
for i in xrange(200, 400):
|
||||
d.append(i)
|
||||
for i in reversed(xrange(-200, 0)):
|
||||
|
|
|
@ -881,6 +881,10 @@ Library
|
|||
Extension Modules
|
||||
-----------------
|
||||
|
||||
- Bug #1604: collections.deque.__init__(iterable) now clears any prior contents
|
||||
before adding elements from the iterable. This fix brings the behavior into
|
||||
line with that for list.__init__().
|
||||
|
||||
- Added wide char functions to msvcrt module: getwch, getwche, putwch and
|
||||
ungetwch. The functions accept or return unicode.
|
||||
|
||||
|
|
|
@ -843,6 +843,7 @@ deque_init(dequeobject *deque, PyObject *args, PyObject *kwdargs)
|
|||
}
|
||||
}
|
||||
deque->maxlen = maxlen;
|
||||
deque_clear(deque);
|
||||
if (iterable != NULL) {
|
||||
PyObject *rv = deque_extend(deque, iterable);
|
||||
if (rv == NULL)
|
||||
|
|
Loading…
Reference in New Issue