summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_generators.py
Commit message (Collapse)AuthorAgeFilesLines
* normalize exceptions passed to the __exit__ method #7853Benjamin Peterson2010-02-051-0/+11
| | | | | | | | | In Python 2.x, exceptions in finally blocks are not normalized. Since with statements are implemented using finally blocks, ceval.c had to be tweaked to distinguish between with finally blocks and normal ones. A test for the finalization of generators containing with statements was also added.
* use closuresBenjamin Peterson2009-06-191-3/+3
|
* show that this one isn't usedBenjamin Peterson2009-06-191-1/+1
|
* remove error checks already done in set_context()Benjamin Peterson2009-06-081-1/+1
|
* fix since difference formating of SyntaxErrorsBenjamin Peterson2009-04-071-4/+8
|
* #4748 lambda generators shouldn't return valuesBenjamin Peterson2008-12-271-0/+10
|
* Make generator repr consistent with function and code object repr.Georg Brandl2008-05-161-1/+1
|
* #2863: add gen.__name__ and add this name to generator repr().Georg Brandl2008-05-151-0/+11
|
* #1473257: add generator.gi_code attribute that refers toGeorg Brandl2008-01-261-1/+19
| | | | the original code object backing the generator. Patch by Collin Winter.
* Patch #1537 from Chad AustinChristian Heimes2007-12-031-0/+13
| | | | | Change GeneratorExit's base class from Exception to BaseException (This time I'm applying the patch to the correct sandbox.)
* Generators had their throw() method allowing string exceptions. That's aBrett Cannon2007-09-111-1/+1
| | | | | | | no-no. Fixes issue #1147. Need to fix 2.5 to raise a proper warning if a string exception is passed in.
* When printing an unraisable error, don't print exceptions. before the name.Neal Norwitz2007-02-261-2/+2
| | | | This duplicates the behavior whening normally printing exceptions.
* Patch #1531113: Fix augmented assignment with yield expressions.Neal Norwitz2006-07-301-3/+36
| | | | Also fix a SystemError when trying to assign to yield expressions.
* Patch #1346214: correctly optimize away "if 0"-style stmtsGeorg Brandl2006-06-041-3/+3
| | | | (thanks to Neal for review)
* Add missing DECREF to PyErr_WriteUnraisable(). That function reportsThomas Wouters2006-04-151-2/+34
| | | | | | | | | | | exceptions that can't be raised any further, because (for instance) they occur in __del__ methods. The coroutine tests in test_generators was triggering this leak. Remove the leakers' testcase, and add a simpler testcase that explicitly tests this leak to test_generators. test_generators now no longer leaks at all, on my machine. This fix may also solve other leaks, but my full refleakhunting run is still busy, so who knows?
* Consolidate 'leak_test1' and 'refleaks_tests', since they both test for theThomas Wouters2006-04-151-17/+15
| | | | same kind of thing.
* Add missing PyObject_GC_Track call, causing *some* itertools.tee objects toThomas Wouters2006-04-151-17/+6
| | | | | | | | | not be tracked by GC. This fixes 254 of test_generators' refleaks on my machine, but I'm sure something else will make them come back :> Not adding a separate test for this kind of cycle, since the existing fib/m235 already test them in more extensive ways than any 'minimal' test has been able to manage.
* Changed comments to make sense now that the LazyList-basedTim Peters2006-04-151-4/+6
| | | | | | | | | | | | | | | | | examples no longer require any explicit closing to avoid leaking. That the tee-based examples still do is (I think) still a mystery. Part of the mystery is that gc.garbage remains empty: if it were the case that some generator in a trash cycle said it needed finalization, suppressing collection of that cycle, that generator _would_ show up in gc.garbage. So this is acting more like, e.g., some tp_traverse slot isn't visiting all the pointers it should (in which case the skipped pointer(s) would act like an external root, silently suppressing collection of everything reachable from it(them)).
* Fix SF#1470508: crash in generator cycle finalization. There were twoPhillip J. Eby2006-04-151-7/+0
| | | | | | | | | | | problems: first, PyGen_NeedsFinalizing() had an off-by-one bug that prevented it from ever saying a generator didn't need finalizing, and second, frame objects cleared themselves in a way that caused their owning generator to think they were still executable, causing a double deallocation of objects on the value stack if there was still a loop on the block stack. This revision also removes some unnecessary close() operations from test_generators that are now appropriately handled by the cycle collector.
* Move the old test_generator_cycle.py which leaked but was removed into the testNeal Norwitz2006-04-141-0/+17
|
* Fix the reference leak in test_generators, by explicitly breaking the cycleThomas Wouters2006-03-311-9/+19
| | | | | | we are about to leave behind. An example of the cause of this leak can be found in the leakers directory, in case we ever want to tackle the underlying problem.
* In true regression-test spirit, make sure theThomas Wouters2006-03-281-0/+29
| | | | | | | | itertools.tee->instance->attribute->itertools.tee and itertools.tee->teedataobject->itertools.tee cycles, which can be found now that itertools.tee and its teedataobject participate in GC, remain findable and cleanable. The test won't fail when they aren't, but at least the frequent hunt-refleaks runs would spot the rise in refleaks.
* Support throw() of string exceptions.Phillip J. Eby2006-03-251-2/+4
|
* Whitespace normalization.Tim Peters2005-12-251-1/+1
|
* Improve test coverage. Hope the test_file changes work the same on windows.Neal Norwitz2005-11-271-0/+5
|
* Revert previous checkin:Neal Norwitz2005-10-221-1/+1
| | | | | | According to Jeremy, the comment only made sense when the yield was disallowed. Now it's testing that the yield is allowed, so it's not bad and the outer finally is irrelevant.
* Add comment lost from AST mergeNeal Norwitz2005-10-211-1/+1
|
* Merge ast-branch to headJeremy Hylton2005-10-201-1/+1
| | | | | | | | | | This change implements a new bytecode compiler, based on a transformation of the parse tree to an abstract syntax defined in Parser/Python.asdl. The compiler implementation is not complete, but it is in stable enough shape to run the entire test suite excepting two disabled tests.
* Whitespace normalization (via reindent.py).Tim Peters2005-08-261-3/+3
|
* [ 1113421 ] New tutorial tests in test_generators.pyGeorg Brandl2005-08-241-0/+78
|
* Whitespace normalization (ran reindent.py over the whole tree).Tim Peters2005-08-071-10/+10
|
* PEP 342 implementation. Per Guido's comments, the generator throw()Phillip J. Eby2005-08-021-15/+261
| | | | | method still needs to support string exceptions, and allow None for the third argument. Documentation updates are needed, too.
* DocTestFinder._find(): for tests derived from a module __test__ global,Tim Peters2004-09-131-6/+6
| | | | | doctest always promised to stick "__test__" in the name. That got broken. Now it's fixed again.
* Removed old "if 0:" block for leak detection; wouldn't work anymore anyway.Tim Peters2004-08-271-8/+1
|
* Don't really need ellipsis doctests for the syntax errors, becauseTim Peters2004-08-271-12/+12
| | | | | | this module imports itself explicitly from test (so the "file names" current doctest synthesizes for examples don't vary depending on how test_generators is run).
* Fixed 6 failures due to doctest changes.Tim Peters2004-08-271-16/+16
|
* Fixed doctest error (wrong prompts)Edward Loper2004-08-091-3/+3
|
* Replace backticks with repr() or "%r"Walter Dörwald2004-02-121-1/+1
| | | | From SF patch #852334.
* This test depends on the exact ordering produced by the WichmannHillRaymond Hettinger2002-12-301-3/+3
| | | | | random number generator. Altered it a bit to use the old generator and restore the test.
* Add tests for weakref support for generator-iterators.Fred Drake2002-08-091-1/+27
| | | | Part of fixing SF bug #591704.
* Get rid of relative imports in all unittests. Now anything thatBarry Warsaw2002-07-231-1/+3
| | | | | | | | | | | 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. :)
* Whitespace normalization.Tim Peters2002-07-161-1/+1
|
* SF bug 567538: Generator can crash the interpreter (Finn Bock).Guido van Rossum2002-06-121-0/+20
| | | | | | | | | | This was a simple typo. Strange that the compiler didn't catch it! Instead of WHY_CONTINUE, two tests used CONTINUE_LOOP, which isn't a why_code at all, but an opcode; but even though 'why' is declared as an enum, comparing it to an int is apparently not even worth a warning -- not in gcc, and not in VC++. :-( Will fix in 2.2 too.
* Add the 'bool' type and its values 'False' and 'True', as described inGuido van Rossum2002-04-031-12/+12
| | | | | | | | | | | | | PEP 285. Everything described in the PEP is here, and there is even some documentation. I had to fix 12 unit tests; all but one of these were printing Boolean outcomes that changed from 0/1 to False/True. (The exception is test_unicode.py, which did a type(x) == type(y) style comparison. I could've fixed that with a single line using issubtype(x, type(y)), but instead chose to be explicit about those places where a bool is expected. Still to do: perhaps more documentation; change standard library modules to return False/True from predicates.
* Remove some now-obsolete generator future statements.Tim Peters2002-04-011-2/+0
| | | | | I left the email pkg alone; I'm not sure how Barry would like to handle that.
* SF patch 499062: Minor typo in test_generators.py.Tim Peters2002-03-101-1/+1
| | | | | | There's no actual patch there. It's an objection that Guido's example doesn't actually generator "leaves", so change the comment that says it does.
* SF bug #488514: -Qnew needs workTim Peters2001-12-061-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Big Hammer to implement -Qnew as PEP 238 says it should work (a global option affecting all instances of "/"). pydebug.h, main.c, pythonrun.c: define a private _Py_QnewFlag flag, true iff -Qnew is passed on the command line. This should go away (as the comments say) when true division becomes The Rule. This is deliberately not exposed to runtime inspection or modification: it's a one-way one-shot switch to pretend you're using Python 3. ceval.c: when _Py_QnewFlag is set, treat BINARY_DIVIDE as BINARY_TRUE_DIVIDE. test_{descr, generators, zipfile}.py: fiddle so these pass under -Qnew too. This was just a matter of s!/!//! in test_generators and test_zipfile. test_descr was trickier, as testbinop() is passed assumptions that "/" is the same as calling a "__div__" method; put a temporary hack there to call "__truediv__" instead when the method name is "__div__" and 1/2 evaluates to 0.5. Three standard tests still fail under -Qnew (on Windows; somebody please try the Linux tests with -Qnew too! Linux runs a whole bunch of tests Windows doesn't): test_augassign test_class test_coercion I can't stay awake longer to stare at this (be my guest). Offhand cures weren't obvious, nor was it even obvious that cures are possible without major hackery. Question: when -Qnew is in effect, should calls to __div__ magically change into calls to __truediv__? See "major hackery" at tail end of last paragraph <wink>.
* Teach regrtest how to pass on doctest failure msgs. This is done via aTim Peters2001-09-091-5/+5
| | | | | | | | | | | horridly inefficient hack in regrtest's Compare class, but it's about as clean as can be: regrtest has to set up the Compare instance before importing a test module, and by the time the module *is* imported it's too late to change that decision. The good news is that the more tests we convert to unittest and doctest, the less the inefficiency here matters. Even now there are few tests with large expected-output files (the new cost here is a Python-level call per .write() when there's an expected- output file).
* Make dir() wordier (see the new docstring). The new behavior is a mixedTim Peters2001-09-031-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | bag. It's clearly wrong for classic classes, at heart because a classic class doesn't have a __class__ attribute, and I'm unclear on whether that's feature or bug. I'll repair this once I find out (in the meantime, dir() applied to classic classes won't find the base classes, while dir() applied to a classic-class instance *will* find the base classes but not *their* base classes). Please give the new dir() a try and see whether you love it or hate it. The new dir([]) behavior is something I could come to love. Here's something to hate: >>> class C: ... pass ... >>> c = C() >>> dir(c) ['__doc__', '__module__'] >>> The idea that an instance has a __doc__ attribute is jarring (of course it's really c.__class__.__doc__ == C.__doc__; likewise for __module__). OTOH, the code already has too many special cases, and dir(x) doesn't have a compelling or clear purpose when x isn't a module.
* The change of type(None).__name__ from 'None' to 'NoneType' broke thisGuido van Rossum2001-08-161-2/+2
| | | | test in a trivial way. Fixed.