From: <pj...@us...> - 2010-04-13 02:16:20
|
Revision: 7024 http://jython.svn.sourceforge.net/jython/?rev=7024&view=rev Author: pjenvey Date: 2010-04-13 02:16:14 +0000 (Tue, 13 Apr 2010) Log Message: ----------- fix throw on a just started generator not fully stopping it fixes #1385 Modified Paths: -------------- trunk/jython/Lib/test/test_generators_jy.py trunk/jython/NEWS trunk/jython/src/org/python/core/PyGenerator.java Modified: trunk/jython/Lib/test/test_generators_jy.py =================================================================== --- trunk/jython/Lib/test/test_generators_jy.py 2010-04-13 00:35:47 UTC (rev 7023) +++ trunk/jython/Lib/test/test_generators_jy.py 2010-04-13 02:16:14 UTC (rev 7024) @@ -1,7 +1,7 @@ from __future__ import generators import unittest -#tests for deeply nested try/except/finally's +# tests for deeply nested try/except/finally's class FinallyTests(unittest.TestCase): def gen1(self): @@ -160,5 +160,13 @@ def testExcept(self): self.assertEquals([1, 1, 1], list(self.genNestedExcept())) +class TestThrowTestCase(unittest.TestCase): + + def test_just_started_throw(self): + genexp = (i for i in range(2)) + self.assertRaises(IOError, genexp.throw, IOError) + self.assertEqual(genexp.gi_frame, None) + self.assertRaises(StopIteration, genexp.next) + if __name__ == "__main__": unittest.main() Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2010-04-13 00:35:47 UTC (rev 7023) +++ trunk/jython/NEWS 2010-04-13 02:16:14 UTC (rev 7024) @@ -31,6 +31,7 @@ - [ 1483 ] optparse std module dies on non-ASCII unicode data - [ 1390 ] ihooks fails due to unimplemented methods in imp module - [ 1456 ] sys.trace/profile attributes cause: AttributeError: write-only attr: trace in PyAMF + - [ 1385 ] generator.throw uncaught on new generator doesn't stop the generator - Fix runtime issues during exitfuncs triggered via SystemRestart (such as during Django or Pylons development mode reloading) - Fix pickling of collections.defaultdict objects Modified: trunk/jython/src/org/python/core/PyGenerator.java =================================================================== --- trunk/jython/src/org/python/core/PyGenerator.java 2010-04-13 00:35:47 UTC (rev 7023) +++ trunk/jython/src/org/python/core/PyGenerator.java 2010-04-13 02:16:14 UTC (rev 7024) @@ -93,6 +93,7 @@ private PyObject raiseException(PyException ex) { if (gi_frame == null || gi_frame.f_lasti == 0) { + gi_frame = null; throw ex; } gi_frame.setGeneratorInput(ex); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |