summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_iter.py
Commit message (Collapse)AuthorAgeFilesLines
* Anti-registration of various ABC methods.Guido van Rossum2016-08-181-0/+12
| | | | | | | | | | - Issue #25958: Support "anti-registration" of special methods from various ABCs, like __hash__, __iter__ or __len__. All these (and several more) can be set to None in an implementation class and the behavior will be as if the method is not defined at all. (Previously, this mechanism existed only for __hash__, to make mutable classes unhashable.) Code contributed by Andrew Barnert and Ivan Levkivskyi.
* Issue #26492: Added additional tests for exhausted iterators of mutable ↵Serhiy Storchaka2016-03-301-0/+11
| | | | sequences.
* Issue #26494: Fixed crash on iterating exhausting iterators.Serhiy Storchaka2016-03-301-0/+4
| | | | | | Affected classes are generic sequence iterators, iterators of str, bytes, bytearray, list, tuple, set, frozenset, dict, OrderedDict, corresponding views and os.scandir() iterator.
* Issue #26015: Added new tests for pickling iterators of mutable sequences.Serhiy Storchaka2016-03-061-0/+36
|
* Issue #23985: Fixed integer overflow in iterator object. Patch bySerhiy Storchaka2015-05-211-0/+25
| | | | Clement Rouault.
* Issue #22777: Test pickling with all protocols.Serhiy Storchaka2014-12-151-16/+17
|
* #7782: merge with 3.3.Ezio Melotti2012-11-181-0/+15
|
* Issue #14288: Serialization support for builtin iterators.Kristján Valur Jónsson2012-04-031-8/+35
|
* Merged revisions 82167 via svnmerge fromBenjamin Peterson2010-06-221-4/+3
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r82167 | benjamin.peterson | 2010-06-22 15:32:02 -0500 (Tue, 22 Jun 2010) | 1 line mark ref counting as impl detail ........
* Merged revisions 82165 via svnmerge fromBenjamin Peterson2010-06-221-1/+3
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r82165 | benjamin.peterson | 2010-06-22 15:26:20 -0500 (Tue, 22 Jun 2010) | 1 line must force gc here ........
* use assert[Not]In where appropriateBenjamin Peterson2010-01-191-10/+10
| | | | A patch from Dave Malcolm.
* convert old fail* assertions to assert*Benjamin Peterson2009-06-301-11/+11
|
* Merged revisions 68560 via svnmerge fromAmaury Forgeot d'Arc2009-01-121-0/+22
| | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r68560 | amaury.forgeotdarc | 2009-01-13 00:36:55 +0100 (mar., 13 janv. 2009) | 6 lines #3720: Interpreter crashes when an evil iterator removes its own next function. Now the slot is filled with a function that always raises. Will not backport: extensions compiled with 2.6.x would not run on 2.6.0. ........
* #2621 rename test.test_support to test.supportBenjamin Peterson2008-05-201-1/+1
|
* Replace map(None, *iterables) with zip(*iterables).Raymond Hettinger2008-01-221-8/+0
|
* Raise statement normalization in Lib/test/.Collin Winter2007-08-291-1/+1
|
* Merged revisions 56125-56153 via svnmerge fromGuido van Rossum2007-07-031-16/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/p3yk ........ r56127 | georg.brandl | 2007-06-30 09:32:49 +0200 (Sat, 30 Jun 2007) | 2 lines Fix a place where floor division would be in order. ........ r56135 | guido.van.rossum | 2007-07-01 06:13:54 +0200 (Sun, 01 Jul 2007) | 28 lines Make map() and filter() identical to itertools.imap() and .ifilter(), respectively. I fixed two bootstrap issues, due to the dynamic import of itertools: 1. Starting python requires that map() and filter() are not used until site.py has added build/lib.<arch> to sys.path. 2. Building python requires that setup.py and distutils and everything they use is free of map() and filter() calls. Beyond this, I only fixed the tests in test_builtin.py. Others, please help fixing the remaining tests that are now broken! The fixes are usually simple: a. map(None, X) -> list(X) b. map(F, X) -> list(map(F, X)) c. map(lambda x: F(x), X) -> [F(x) for x in X] d. filter(F, X) -> list(filter(F, X)) e. filter(lambda x: P(x), X) -> [x for x in X if P(x)] Someone, please also contribute a fixer for 2to3 to do this. It can leave map()/filter() calls alone that are already inside a list() or sorted() call or for-loop. Only in rare cases have I seen code that depends on map() of lists of different lengths going to the end of the longest, or on filter() of a string or tuple returning an object of the same type; these will need more thought to fix. ........ r56136 | guido.van.rossum | 2007-07-01 06:22:01 +0200 (Sun, 01 Jul 2007) | 3 lines Make it so that test_decimal fails instead of hangs, to help automated test runners. ........ r56139 | georg.brandl | 2007-07-01 18:20:58 +0200 (Sun, 01 Jul 2007) | 2 lines Fix a few test cases after the map->imap change. ........ r56142 | neal.norwitz | 2007-07-02 06:38:12 +0200 (Mon, 02 Jul 2007) | 1 line Get a bunch more tests passing after converting map/filter to return iterators. ........ r56147 | guido.van.rossum | 2007-07-02 15:32:02 +0200 (Mon, 02 Jul 2007) | 4 lines Fix the remaining failing unit tests (at least on OSX). Also tweaked urllib2 so it doesn't raise socket.gaierror when all network interfaces are turned off. ........
* Simplify various spots where: str() is called on somethingWalter Dörwald2007-06-111-1/+1
| | | | | | that already is a string or the existence of the str class is checked or a check is done for str twice. These all stem from the initial unicode->str replacement.
* Remove have_unicode checks and merge those tests into theWalter Dörwald2007-05-221-12/+2
| | | | | normal code (or drop them if they only repeat previous tests).
* Merged revisions 55007-55179 via svnmerge fromGuido van Rossum2007-05-071-33/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/p3yk ........ r55077 | guido.van.rossum | 2007-05-02 11:54:37 -0700 (Wed, 02 May 2007) | 2 lines Use the new print syntax, at least. ........ r55142 | fred.drake | 2007-05-04 21:27:30 -0700 (Fri, 04 May 2007) | 1 line remove old cruftiness ........ r55143 | fred.drake | 2007-05-04 21:52:16 -0700 (Fri, 04 May 2007) | 1 line make this work with the new Python ........ r55162 | neal.norwitz | 2007-05-06 22:29:18 -0700 (Sun, 06 May 2007) | 1 line Get asdl code gen working with Python 2.3. Should continue to work with 3.0 ........ r55164 | neal.norwitz | 2007-05-07 00:00:38 -0700 (Mon, 07 May 2007) | 1 line Verify checkins to p3yk (sic) branch go to 3000 list. ........ r55166 | neal.norwitz | 2007-05-07 00:12:35 -0700 (Mon, 07 May 2007) | 1 line Fix this test so it runs again by importing warnings_test properly. ........ r55167 | neal.norwitz | 2007-05-07 01:03:22 -0700 (Mon, 07 May 2007) | 8 lines So long xrange. range() now supports values that are outside -sys.maxint to sys.maxint. floats raise a TypeError. This has been sitting for a long time. It probably has some problems and needs cleanup. Objects/rangeobject.c now uses 4-space indents since it is almost completely new. ........ r55171 | guido.van.rossum | 2007-05-07 10:21:26 -0700 (Mon, 07 May 2007) | 4 lines Fix two tests that were previously depending on significant spaces at the end of a line (and before that on Python 2.x print behavior that has no exact equivalent in 3.0). ........
* Rip out all the u"..." literals and calls to unicode().Guido van Rossum2007-05-021-5/+5
|
* PEP 3114: rename .next() to .__next__() and add next() builtin.Georg Brandl2007-04-211-7/+7
|
* Fix test_iter after the dict views conversion.Brett Cannon2007-02-221-7/+7
|
* - PEP 3106: dict.iterkeys(), .iteritems(), .itervalues() are now gone;Guido van Rossum2007-02-111-14/+14
| | | | | | | | | | and .keys(), .items(), .values() return dict views. The dict views aren't fully functional yet; in particular, they can't be compared to sets yet. but they are useful as "iterator wells". There are still 27 failing unit tests; I expect that many of these have fairly trivial fixes, but there are so many, I could use help.
* - patch #1600346 submitted by Tomer FilibaJack Diederich2006-11-281-3/+3
| | | | | | - Renamed nb_nonzero slots to nb_bool - Renamed __nonzero__ methods to __bool__ - update core, lib, docs, and tests to match
* Make built-in zip() equal to itertools.izip().Guido van Rossum2006-08-241-13/+16
| | | | | | | I mea, *really* equal -- for now, the implementation just imports itertools. :-) The only other changes necessary were various unit tests that were assuming zip() returns a real list. No "real" code made this assumption.
* Anna Ravenscroft identified many occurrences of "file" used to open a fileAlex Martelli2006-08-241-2/+2
| | | | | | in the stdlib and changed each of them to use "open" instead. At this time there are no other known occurrences that can be safely changed (in Lib and all subdirectories thereof).
* Kill reduce(). A coproduction of John Reese, Jacques Frechet, and Alex M.Guido van Rossum2006-08-221-13/+0
|
* As discussed on python-dev, changed builtin.zip() to handle zero argumentsRaymond Hettinger2003-08-021-1/+4
| | | | by returning an empty list instead of raising a TypeError.
* Don't rebind True and False.Tim Peters2002-12-231-5/+5
|
* Mark xreadlines deprecated. Don't use f.xreadlines() in test_iter.py.Guido van Rossum2002-08-061-2/+2
|
* Get rid of relative imports in all unittests. Now anything thatBarry Warsaw2002-07-231-1/+1
| | | | | | | | | | | imports e.g. test_support must do so using an absolute package name such as "import test.test_support" or "from test import test_support". This also updates the README in Lib/test, and gets rid of the duplicate data dirctory in Lib/test/data (replaced by Lib/email/test/data). Now Tim and Jack can have at it. :)
* Bunch of tests to make sure that StopIteration is a sink state.Guido van Rossum2002-07-161-0/+76
|
* builtin_zip(): Take a good guess at how big the result list will be,Tim Peters2002-04-291-0/+28
| | | | | | | and allocate it in one gulp. This isn't a bugfix, it's just a minor optimization that may or may not pay off.
* unpack_iterable(): Add a missing DECREF in an error case. Reported byGuido van Rossum2001-12-031-0/+23
| | | | | Armin Rigo (SF bug #488477). Added a testcase to test_unpack_iter() in test_iter.py.
* Whitespace normalization.Tim Peters2001-10-041-4/+4
|
* Generalize file.writelines() to allow iterable objects.Tim Peters2001-09-231-0/+53
|
* Change the PyUnit-based tests to use the test_main() approach. ThisFred Drake2001-09-201-1/+7
| | | | | allows using the tests with unittest.py as a script. The tests will still run when run as a script themselves.
* Generalize operator.indexOf (PySequence_Index) to work with anyTim Peters2001-09-081-0/+41
| | | | | | | | | | iterable object. I'm not sure how that got overlooked before! Got rid of the internal _PySequence_IterContains, introduced a new internal _PySequence_IterSearch, and rewrote all the iteration-based "count of", "index of", and "is the object in it or not?" routines to just call the new function. I suppose it's slower this way, but the code duplication was getting depressing.
* Patch #445762: Support --disable-unicodeMartin v. Löwis2001-08-171-5/+11
| | | | | | | | - Do not compile unicodeobject, unicodectype, and unicodedata if Unicode is disabled - check for Py_USING_UNICODE in all places that use Unicode functions - disables unicode literals, and the builtin functions - add the types.StringTypes list - remove Unicode literals from most tests.
* Teach the UNPACK_SEQUENCE opcode how to tease an iterable object intoTim Peters2001-06-211-0/+53
| | | | | giving up the goods. NEEDS DOC CHANGES
* Generalize zip() to work with iterators.Tim Peters2001-05-061-0/+46
| | | | | | | | NEEDS DOC CHANGES. More AttributeErrors transmuted into TypeErrors, in test_b2.py, and, again, this strikes me as a good thing. This checkin completes the iterator generalization work that obviously needed to be done. Can anyone think of others that should be changed?
* Get rid of silly 5am "del" stmts.Tim Peters2001-05-051-2/+0
|
* Reimplement PySequence_Contains() and instance_contains(), so they workTim Peters2001-05-051-18/+6
| | | | | | | | | safely together and don't duplicate logic (the common logic was factored out into new private API function _PySequence_IterContains()). Visible change: some_complex_number in some_instance no longer blows up if some_instance has __getitem__ but neither __contains__ nor __iter__. test_iter changed to ensure that remains true.
* Generalize PySequence_Count() (operator.countOf) to work with iterators.Tim Peters2001-05-051-0/+35
|
* Make 'x in y' and 'x not in y' (PySequence_Contains) play nice w/ iterators.Tim Peters2001-05-051-0/+55
| | | | | | | | | | | | | NEEDS DOC CHANGES A few more AttributeErrors turned into TypeErrors, but in test_contains this time. The full story for instance objects is pretty much unexplainable, because instance_contains() tries its own flavor of iteration-based containment testing first, and PySequence_Contains doesn't get a chance at it unless instance_contains() blows up. A consequence is that some_complex_number in some_instance dies with a TypeError unless some_instance.__class__ defines __iter__ but does not define __getitem__.
* Make unicode.join() work nice with iterators. This also required a changeTim Peters2001-05-051-0/+41
| | | | | | | | to string.join(), so that when the latter figures out in midstream that it really needs unicode.join() instead, unicode.join() can actually get all the sequence elements (i.e., there's no guarantee that the sequence passed to string.join() can be iterated over *again* by unicode.join(), so string.join() must not pass on the original sequence object anymore).
* Generalize tuple() to work nicely with iterators.Tim Peters2001-05-051-0/+33
| | | | | | | | | | | | | | | | | | | | | NEEDS DOC CHANGES. This one surprised me! While I expected tuple() to be a no-brainer, turns out it's actually dripping with consequences: 1. It will *allow* the popular PySequence_Fast() to work with any iterable object (code for that not yet checked in, but should be trivial). 2. It caused two std tests to fail. This because some places used PyTuple_Sequence() (the C spelling of tuple()) as an indirect way to test whether something *is* a sequence. But tuple() code only looked for the existence of sq->item to determine that, and e.g. an instance passed that test whether or not it supported the other operations tuple() needed (e.g., __len__). So some things the tests *expected* to fail with an AttributeError now fail with a TypeError instead. This looks like an improvement to me; e.g., test_coercion used to produce 559 TypeErrors and 2 AttributeErrors, and now they're all TypeErrors. The error details are more informative too, because the places calling this were *looking* for TypeErrors in order to replace the generic tuple() "not a sequence" msg with their own more specific text, and AttributeErrors snuck by that.
* Generalize reduce() to work with iterators.Tim Peters2001-05-041-0/+13
| | | | NEEDS DOC CHANGES.
* Purge redundant cut&paste line.Tim Peters2001-05-031-2/+1
|