Kaydet (Commit) adf9ffdf authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Fix bug 1604. deque.__init__() did not clear existing contents like…

Fix bug 1604. deque.__init__() did not clear existing contents like list.__init__. Not a backport candidate.
üst 842c1784
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment