classification
Title: new test for test_iter.py
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ezio.melotti Nosy List: Steve Howell, ezio.melotti, python-dev, rhettinger
Priority: normal Keywords: patch

Created on 2010-01-26 08:12 by Steve Howell, last changed 2012-11-18 21:19 by ezio.melotti. This issue is now closed.

Files
File name Uploaded Description Edit
extend_test.diff Steve Howell, 2010-01-29 17:57
Messages (7)
msg98320 - (view) Author: showell (Steve Howell) Date: 2010-01-26 08:12
I would like to submit the following test to be part of the test_iter.py test suite:

    def test_extends(self):
        # This test would break on an incomplete patch to listobject.c
        def gen():
            for i in range(500):
                yield i
        lst = [0] * 500
        for i in range(240):
            lst.pop(0)
        lst.extend(gen())

The history behind it is that I made a patch to listobject.c that obviously broke listextend(), but the tests did not catch it.  This was my failing test to improve my patch.  Regardless of what happens to the patch, I think it's a good idea to hammer on listextend() when it accepts an iterator, as it's a fairly tricky problem to extend a list when you do not know in advance how long it will be until the iterator gets exhausted.
msg98339 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-01-26 15:01
From the comment ("This test would break on an incomplete patch to listobject.c") is not clear what exactly the test is supposed to check.
Probably the test should include some assert* or more comments if it is supposed to work but it might raise an error if there's something wrong.
Finally it would be better if you can provide a patch against trunk and attach it to the issue.
msg98519 - (view) Author: showell (Steve Howell) Date: 2010-01-29 17:57
Per Ezio's suggestions, I added clearer comments and an assert, and now the attached diff applies to trunk.
msg101591 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-03-23 18:41
Can you produce a more tightly focused test, the minimum code that would have segfaulted your change?
msg101623 - (view) Author: showell (Steve Howell) Date: 2010-03-24 06:49
My proposed test is final.  Please either accept or reject it as is.  I assume it runs pretty quickly, so I am not sure what the cost fear is.  The benefit of accepting the test is that it would potentially catch bugs on changes to the implementation of list.
msg175922 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-11-18 21:16
New changeset 4624570c1f19 by Ezio Melotti in branch '2.7':
#7782: add a test for test_iter.
http://hg.python.org/cpython/rev/4624570c1f19

New changeset d2054aa9bed4 by Ezio Melotti in branch '3.2':
#7782: add a test for test_iter.
http://hg.python.org/cpython/rev/d2054aa9bed4

New changeset 0cc209d95e70 by Ezio Melotti in branch '3.3':
#7782: merge with 3.2.
http://hg.python.org/cpython/rev/0cc209d95e70

New changeset d2b98a4c4251 by Ezio Melotti in branch 'default':
#7782: merge with 3.3.
http://hg.python.org/cpython/rev/d2b98a4c4251
msg175923 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-11-18 21:19
I committed the patch as is.
It run fast enough that I cannot notice any slowdown.
History
Date User Action Args
2012-11-18 21:19:29ezio.melottisetstatus: open -> closed
versions: + Python 3.3, Python 3.4, - Python 2.6, Python 3.1
messages: + msg175923

assignee: ezio.melotti
resolution: fixed
stage: patch review -> resolved
2012-11-18 21:16:17python-devsetnosy: + python-dev
messages: + msg175922
2010-03-24 06:49:35Steve Howellsetmessages: + msg101623
2010-03-23 18:41:45rhettingersetmessages: + msg101591
2010-01-29 18:48:27pitrousetnosy: + rhettinger
2010-01-29 17:57:23Steve Howellsetfiles: + extend_test.diff
keywords: + patch
messages: + msg98519
2010-01-26 15:01:16ezio.melottisetpriority: normal
versions: + Python 2.6, Python 3.1, Python 2.7
nosy: + ezio.melotti

messages: + msg98339

stage: patch review
2010-01-26 08:12:04Steve Howellcreate